Title: Mac OS X: python-config --ldflags and location of Python.framework
Type: behavior Stage: resolved
Components: Build Versions: Python 2.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Andrew.Jaffe, esc24, hynek, ned.deily, python-dev, ronaldoussoren, samueljohn
Priority: normal Keywords: patch

Created on 2013-01-03 11:32 by samueljohn, last changed 2013-03-04 22:40 by ned.deily. This issue is now closed.

File name Uploaded Description Edit
issue16848.patch ronaldoussoren, 2013-02-27 12:39
Messages (7)
msg178936 - (view) Author: Samuel John (samueljohn) Date: 2013-01-03 11:32
Some tools use `python-config --ldflags` to get the flags in order to link against the Python lib on OS X (for example gst-python from pygtk (2.x).

For framework builds, `python-config --ldflags` returns (among few other):

    -u _PyMac_Error Python.framework/Versions/2.7/Python

which is an incomplete path.

This issue is almost a duplicate of and the fix discussed there would work. However I report this for Python 2.7.

We at Homebrew propose a very similar fix but I'd prefer the one in issue3588:

    LINKFORSHARED = -u _PyMac_Error -framework Python
msg178937 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2013-01-03 11:49
Using '-framework Python' is suboptimal because this doesn't control which framework is used for linking (in particular, if you have both Python 2.7 and 3.3 installed '-framework Python' will link against the one installed last).

For Python 3.3 I get:

$ /Library/Frameworks/Python.framework/Versions/3.2/bin/python3-config --ldflags
-L/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/config-3.2m -ldl -framework CoreFoundation -lpython3.2m

Simular output would also work for python 2.7 (but I don't have a patch right now)
msg178951 - (view) Author: Samuel John (samueljohn) Date: 2013-01-03 15:27
Agreed. My patch, I did for Homebrew is to use the full path like so:

    PYTHONFRAMEWORKDIR= full/path/to/Frameworks/Python.framework

instead of just `Python.framework`.
msg183146 - (view) Author: Andrew Jaffe (Andrew.Jaffe) Date: 2013-02-27 12:28
Will this be fixed? I note that the related LINKFORSHARED bug (which causes this, I think) is marked as resolved.
msg183150 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2013-02-27 12:39
With framework build from yesterday this is not fixed for python 2.7, it prints:

-L/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config -ldl -framework CoreFoundation -lpython2.7 -u _PyMac_Error Python.framework/Versions/2.7/Python

The bit and the end it unwanted:

   -u _PyMac_Error Python.framework/Versions/2.7/Python

The attached patch fixes the issue (I haven't committed yet because I don't have time to run the test suite right now). The patch works for me and should be fine as it mirrors the solution in the 3.x tree.

BTW. As noted before linking with '-framework Python' is not what you want to do, this causes problems when someone installs multiple framework versions: '-framework Python' then links to whatever framwork was installed last instead of the python version you ran 'python-config' for.
msg183503 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-03-04 22:32
New changeset bab708624dc4 by Ned Deily in branch '2.7':
Issue #16848: python-config now returns proper --ldflags values for OS X
msg183505 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2013-03-04 22:39
Other than the tabs, the patch LGTM.  I originally noticed the problem when addressing Issue14197, a Python 3 only issue, and fixed it there. But I did not go back and check that the python-config part was also an issue for 2.7.  Now committed for release in 2.7.4.
Date User Action Args
2013-03-04 22:40:07ned.deilysetstatus: open -> closed
2013-03-04 22:39:27ned.deilysetresolution: fixed
messages: + msg183505
stage: needs patch -> resolved
2013-03-04 22:32:03python-devsetnosy: + python-dev
messages: + msg183503
2013-02-27 12:39:09ronaldoussorensetfiles: + issue16848.patch
keywords: + patch
messages: + msg183150
2013-02-27 12:28:15Andrew.Jaffesetnosy: + Andrew.Jaffe
messages: + msg183146
2013-01-04 19:45:11esc24setnosy: + esc24
2013-01-03 15:27:01samueljohnsetmessages: + msg178951
2013-01-03 11:49:17ronaldoussorensetmessages: + msg178937
stage: needs patch
2013-01-03 11:32:54samueljohncreate