I use several versions of Python on my computer : 2.6.6
, 2.7.6
and 2.7.9
. When I compile Boost with boost-python, I have to give the Python to use in argument. If I want compatibility, have I to compile Boost for each Python version ? (it's quite huge !) Or is there a way to use only one build of Boost with several python versions ?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
The official Python development cycle does not describe the stability of the application binary interface (ABI) between releases. For releases before Python 3.2, there is no guarantee for ABI compatibility. For 3.2 and beyond, PEP 384 defines the stable ABI where a subset of the Python/C API is guaranteed to maintain ABI compatibility. To use this subset,
Py_LIMITED_API
needs to be defined when building Boost.Python and extension modules.While it primarily depends on the Python/C API types and functionality being used directly in user code or through Boost.Python, in general:
In all cases where Boost.Python needs to be recompiled, no other Boost library should need to be recompiled. When building multiple versions of Boost.Python, verify a clean build occurs. Without a clean build, Boost.Python may build, but fail to properly link. For example, the
PyClass_Type
symbol should not be referenced in Python 3 Boost.Python builds, but without a clean build, previous build artifacts may populate the library:Note that even though the
3noclean
build was built against Python 3, the previous build that was using Python 2 had artifacts that polluted the3noclean
library. Also, be aware that Boost.Python and user code may need recompiled to match the Python's CPU architecture and UCS-2 or UCS-4 unicode configurations.As of Boost 1.67, you can build boost so it generates a separate version of libboost_python for each version of Python that you specify without having to clean or rebuild as part of the process.
For instance, I edit
tools/build/src/user-config.jam
to contain the versions of Python on the system:Then, I run
./b2 python=2.7,3.5,3.6,3.7
for the build step.Some downstream packages expect the boost python libraries to be called
libboost_python.so
for Python 2.x andlibboost_python3.so
for Python 3.x, and you might need to explicitly specify-lboost_python27
,-lboost_python35
, etc. to get those programs to link properly.