After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 616553 - Configuring gst-python on Mac OS fails: "checking for libraries required to embed python"
Configuring gst-python on Mac OS fails: "checking for libraries required to e...
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gst-python
git master
Other Mac OS
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2010-04-22 19:15 UTC by Leo Singer
Modified: 2011-05-25 19:04 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed patch (584 bytes, patch)
2010-04-22 19:15 UTC, Leo Singer
none Details | Review

Description Leo Singer 2010-04-22 19:15:22 UTC
Created attachment 159355 [details] [review]
Proposed patch

Configuring gst-python on a Mac OS machine with Python installed from MacPorts fails with the following error (taken from config.log):

configure:13861: checking for libraries required to embed python
configure:13888: gcc -o conftest -g -O2   conftest.c  -L/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib -lpython2.6 >&5
/usr/libexec/gcc/i686-apple-darwin8/4.0.1/ld: can't locate file for: -lpython2.6
collect2: ld returned 1 exit status

I find that my Python embedding libraries are not in /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib, but in /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/config, as suggested by python-config.

The attached patch is one possible resolution.
Comment 1 Daniel Macks 2010-04-23 02:24:09 UTC
The PYTHON_LIBS change (asking python itself for its build configuration) is excellent. Assuming that the first parameter in that is the location of the lib (and that there are no embedded spaces in it!) is fragile. And I think that gives you the -L/path flag not just the /path location as the previous would? I'm not sure how PYTHON_LIB_LOC gets used, but there are many python-library packages out there, there's gotta be a standard way to introspect that piece of data too (or work around actually needing it explicitly).
Comment 2 Leo Singer 2010-04-23 03:07:23 UTC
Aha.  In MacPorts, python -c "import sys; print sys.exec_prefix" gives me:
/opt/local/Library/Frameworks/Python.framework/Versions/2.6

but "libpython2.6.dylib" is in /opt/local/lib.  This must be one of the many fragile aspects of MacPorts' strategy for installing multiple Python versions.

Any suggestions?
Comment 3 Leo Singer 2010-04-23 03:10:21 UTC
Maybe this should be reported to MacPorts instead.
Comment 4 Daniel Macks 2010-04-23 05:16:38 UTC
I don't know anything about MacPorts's games there, but there's nothing intrinsically wrong with putting python's shared libs in any wacky place on a system, as long as the way python is documented to publish its lib location is correct for that location. It's as much a bug to assume the lib is in $py_prefix/lib as it is to assume it is in /some/main/prefix/lib as it is to assume it's in $py_prefix/lib/python$PYTHON_VERSION/config.

PYTHON_LIB_LOC needs to be just the pathname though (I assume /opt/local/lib for you) not the linker flag that --ldflags gives (I assume -L/opt/local/lib for you). Doesn't matter though...the interal use of PY_LIB_LOC is hardcoded in a linux-centric manner.
Comment 5 Daniel Macks 2010-04-23 05:42:11 UTC
See Bug #616592 for a more complex problem about how PYTHON_LIB_LOC is handled.
Comment 6 Leo Singer 2010-04-23 06:35:50 UTC
I poked around and found that I have Python shared libraries in 

/opt/local/lib

e.g.

/opt/local/lib/libpython2.6.dylib

but this is a symlink put in place as a "post-destroot" step (not the Python make install, but by the package manager).

They point to: /opt/local/Library/Frameworks/Python.framework/Versions/2.6/Python

which, as confirmed by the "file" command, is a shared library, despite the unusual naming convention.  (Unfortunately, gcc won't understand -lPython in this context, but -F/opt/local/Library/Frameworks -fPython might work because it is a framework.)  This naming convention for shared libraries is standard for Mac OS "frameworks", which don't look like a conventional Linux root directory.  Python was Mac-friendly and made a source release that built into a standard "framework" structure.

Now, the library path hinted at by "python-config" is "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/config".  This directory contains a file called "libpython2.6.a", which despite its name, is a symlink to the one and only shared library, which had the file name "Python".  It looks like the Python "make install" put that there, not the MacPorts "post-destroot" step.

Examining "python-config", which is itself a Python script, suggests that the following command could yield a valid value for PYTHON_LIB_LOC:

python -c "from distutils.sysconfig import get_config_var;print get_config_var('LIBPL')"

However, I tried running this command on a CentOS (Red Hat derived distribution, used at my workplace), and found that the config directory contained a **static** library.

The plot thickens: on CentOS, PYTHON_LIB_LOC gets configured as "/usr/lib", but the needed shared library "libpython2.4.so" is in "/usr/lib64", not "/usr/lib".  Yikes!
Comment 7 Sebastian Dröge (slomo) 2011-05-25 19:03:10 UTC
This should be fixed now in the latest release. The check was improved for OS X.