建有多个版本的Python升压 [英] Build Boost with multiple Python versions

查看:175
本文介绍了建有多个版本的Python升压的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Python的几个版本我的电脑上: 2.6.6 2.7.6 2.7.9 。当我编译升压蟒蛇升压,我不得不放弃在争论使用Python。如果我想的兼容性,有我编译升压每个Python版本?(这是相当巨大的!),或者是有只使用一个构建升压与几个Python版本的方式?

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 ?

推荐答案

官方的Python 开发周期不描述版本之间的应用程序二进制接口(ABI)的稳定性。对于Python 3.2之前的发行,对于ABI兼容性没有保证。对于3.2及以后, PEP 384 定义的稳定ABI 所在的Python / C API的一个子集,是保证维持ABI兼容性。要使用此子集, Py_LIMITED_API 需要构建Boost.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.

虽然它主要取决于Python的/ C API类型和功能被直接用于用户code或通过Boost.Python的,在一般情况:

While it primarily depends on the Python/C API types and functionality being used directly in user code or through Boost.Python, in general:


  • 主要级版本,例如Python 2和Python 3,Boost.Python的和用户code将需要重新编译

  • 轻微级别的版本,如Python 2.6和Python 2.7,Boost.Python的和用户code可能需要重新编译

  • 对于微观层面的发布,Boost.Python的和用户code很少需要重新编译

在哪里Boost.Python的需要重新编译所有的情况下,没有其他Boost库应该需要重新编译。当构建Boost.Python的多个版本,验证清洁的构建进行。如果没有一个干净的构建,Boost.Python的可建,但无法正常链接。例如, PyClass_Type 符号不应该在Python 3引用Boost.Python的构建,但没有一个干净的构建,previous建立文物可以填充库:

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:

$ ./bootstrap.sh --with-python=/usr/bin/python2
...
Detecting Python version... 2.7
$ ./b2 --with-python --buildid=2 # produces libboost_python-2.so
$ ./bootstrap.sh --with-python=/usr/bin/python3 --with-python-root=/usr
...
Detecting Python version... 3.3
$ ./b2 --with-python --buildid=3noclean # produces libboost_python-3noclean.so
$ ./b2 --with-python --clean
$ ./b2 --with-python --buildid=3 # produces libboost_python-3.so

$ nm -D stage/lib/libboost_python-2.so | grep PyClass_Type
                 U PyClass_Type
$ nm -D stage/lib/libboost_python-3noclean.so | grep PyClass_Type
                 U PyClass_Type
$ nm -D stage/lib/libboost_python-3.so | grep PyClass_Type

请注意,即使 3noclean 生成已对Python 3的建造,这是使用Python 2 previous构建有这样的污染 3noclean 库。此外,要注意的Boost.Python和用户code可能需要重新编译了Python的CPU架构和UCS-2或UCS-4 UNI code的配置相匹配。

Note that even though the 3noclean build was built against Python 3, the previous build that was using Python 2 had artifacts that polluted the 3noclean 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.

这篇关于建有多个版本的Python升压的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆