Skip to content Skip to sidebar Skip to footer

Boost Python Portability Concerns

I have a dll written in C++ that I want to export to Python for running regression and unit-testing (it's just easier to maintain and run the regression with Python). To this purpo

Solution 1:

Take a look at PEP 384 at http://docs.python.org/3.2/whatsnew/3.2.html.

http://www.boost.org/doc/libs/1_52_0/libs/python/doc/news.html shows that there hasn't been any real progress lately so I doubt that Boost.Python supports or was at least tested with Py_LIMITED_API defined.

According to my experience with Python 2.x compatibility using both Boost.Python and PyCXX (I haven't worked with 3.x line yet):

  1. No it won't. Only micro version changes stay ABI portable.
  2. Not exactly. The user of a MyLibrary.pyd binary provided by you won't be able to load it using different major/minor python version. The build configuration of Boost she has does not matter. You need to have Boost.Python builds with every minor Python version you want to support. That includes separate builds for 32 and 64 bit Python installations.

My advice is to try to build Boost from source with Py_LIMITED_API defined. I do not guarantee that it will succeed, but it's worth a try.

If it fails ask your teammates to use the same Python version as you and of course a x64 bit Windows (since the .pyd is 64bit itself). Or even better setup a CI machine that will build your python module in every required configuration so that your clients will be able to choose a proper binary. Let your teammates build and use their own versions of MyLibrary.pyd for their local use only.

Post a Comment for "Boost Python Portability Concerns"