简体   繁体   English

pybind c++ 用于多个 python 版本

[英]pybind c++ for multiple python versions

Someone setup for us cmake to use pybind to create a.pyd module we package, together with some pure python files, into a wheel.有人为我们 cmake 设置使用 pybind 创建一个 .pyd 模块我们 package,连同一些纯 python 文件,进入一个轮子。

We are switching from an old 3.7 python to a modern one, so we want to support wheels for both the old and new python version, at least for now.我们正在从旧的 3.7 python 切换到现代版本,因此我们希望支持旧版和新版 python 的轮子,至少现在是这样。

I've read the pybind documentation and, due to my unfamiliarity with cmake, I found it unclear.我已经阅读了 pybind 文档,由于我对 cmake 不熟悉,我发现它不清楚。 So I'm looking for clarification.所以我正在寻求澄清。

My understanding is that you would have to compile twice, one time "targeting" 3.7 and another time targeting the newer version.我的理解是您必须编译两次,一次是“针对”3.7,另一次是针对较新的版本。 But I wouldn't expect this to matter at all (if you were to handcode wrapping to python), or at most I'd expect it to matter if we were targeting two different major version (ie python2 vs python3).但我不认为这有什么关系(如果你要手动编写 python 包装),或者至多我希望它有关系,如果我们针对两个不同的主要版本(即 python2 与 python3)。

My question is if this is really needed.我的问题是这是否真的需要。 Can I just avoid a second compilation and slam the.pyd I get when compiling "for python 3.7" into the wheel we build for the newer python too?我是否可以避免第二次编译并将编译“for python 3.7”时得到的.pyd 猛击到我们为较新的 python 构建的轮子中?

Yes, it is necessary.是的,有必要。 The CPython ABI changes from version to version, often in incompatible ways, so you have to compile for each version separately. CPython ABI 随版本而变化,通常以不兼容的方式变化,因此您必须分别针对每个版本进行编译。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM