Finding the right Python structure with cmake

I am using the python version for macports on a Snow Leopard computer and using cmake to create a cross-platform extension. I am looking for a python interpreter and libraries in the system using the following commands in CMakeLists.txt

include(FindPythonInterp) include(FindPythonLibs ) 

However, while cmake identified the correct interpreter in /opt/local/bin , it tries to associate with the wrong structure, namely the Python system.

 -- Found PythonInterp: /opt/local/bin/python2.6 -- Found PythonLibs: -framework Python 

And this leads to the following runtime error

 Fatal Python error: Interpreter not initialized (version mismatch?) 

Once I replaced -framework Python with /opt/local/Library/Frameworks/Python.framework/Python , it looks like the job is working properly.

How can I make a cmake link against the correct Python structure found in

 /opt/local/Library/Frameworks/Python.framework/Python 

not system in

 /System/Library/Frameworks/Python.framework/Python 

?

+7
python frameworks cmake macports macos
source share
2 answers

Adding the following to ~/.bash_profile

 export DYLD_FRAMEWORK_PATH=/opt/local/Library/Frameworks 

fixes the problem at least temporarily. Apparently, this inconsistency between the python interpreter and the python map used by cmake is a bug that we hope will be fixed in the new version.

+5
source share

I am not familiar with CMake, but with the gcc / ld version for Apple you can pass the -F flag to indicate a new wireframe search path. For example, -F/opt/local/Library/Frameworks will search the MacPorts framework directory. If you can specify such a flag using CMake, it can solve your problem.

+1
source share

All Articles