简体   繁体   中英

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.

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.

I've read the pybind documentation and, due to my unfamiliarity with cmake, I found it unclear. 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. 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).

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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