[Build/Install] graphviz always links against system python
Ported Issue from Mantis Original ID: 2486 Reported By: tdsmith
SEVERITY: IMPORTANT Submitted: 2014-09-09 23:32:36
OS: OS X
OS BUILD: 10.9
PLATFORM: DARWIN
DESCRIPTION
When building the python bindings against e.g. python 2.7, -lpython2.7 is added to the linker command line but the linker's default search path is not modified. When users try to build against Homebrew's python, Homebrew's libpython2.7 is not in the default linker search path so it is not found and the module is linked against the system python framework instead, which causes a segfault on "import gv" from the Homebrew python.
This can be resolved a few different ways, probably in ascending order of correctness:
- add -L$PYTHON_PREFIX/lib to the linker path
- discover python build flags with e.g. python2.7-config --ldflags
- link modules with -undefined dynamic_lookup so that Python symbols are resolved at import time and not at link time, which has the pleasant effect that modules built for one interpreter can be used with another without segfaults
I've provided a patch for option 1.
STEPS TO REPRODUCE
- Install Python from python.org, Homebrew, Enthought, or some other vendor so that "python" invokes the new non-system python interpreter.
- Install graphviz from source.
- Run python -c "import gv" and observe that the interpreter segfaults.
ADDITIONAL INFORMATION
Originally reported to Homebrew as https://github.com/Homebrew/homebrew/issues/32180.