-
Notifications
You must be signed in to change notification settings - Fork 21
Compiling wrappers for multiple versions of Python
When multiple versions of Python are installed and/or Boost Python are installed, the include directories and libraries might be incorrectly detected. Such a case can be easily detected by looking at the dependencies (e.g. odil.so
or odil.dylib
) of the library in the wrappers
subdirectory of the build directory: platform-dependent tools such as ldd
Linux) or otool
(OS X) will show version discrepancies between the Python library (e.g. libpython3.4m.so
) and the Boost.Python library (e.g. libboost_python-py27.so
). Since the naming conventions are not consistent across platforms, it is up to the user to override compile settings in such cases.
The Python version can be forced using TODO
. For fine-tuning, PYTHON_INCLUDE_DIR
and PYTHON_LIBRARY
may also be used. The Boost.Python version can be forced using Boost_PYTHON_LIBRARY_DEBUG
and Boost_PYTHON_LIBRARY_RELEASE
.
For example, on Debian 8 (jessie), the following (broken) CMake invocation selects Python 3.4 with the 2.7 version of Boost.Python:
cmake -D Python_ADDITIONAL_VERSIONS=3.4 ${SOURCE_DIRECTORY}
Assuming that BOOST_PYTHON_34
contains the location of the 3.4 version of Boost.Python (e.g. /usr/lib/x86_64-linux-gnu/libboost_python-py34.so
), the correct invocation of CMake reads:
cmake -D Python_ADDITIONAL_VERSIONS=3.4 -D Boost_PYTHON_LIBRARY_DEBUG=${BOOST_PYTHON_34} -D Boost_PYTHON_LIBRARY_RELEASE=${BOOST_PYTHON_34} ${SOURCE_DIRECTORY}