You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I build on macOS or Linux, the generated extension module has abi3 suffix and can be loaded on different CPython versions (e.g. 3.5 and 3.6).
On Windows however, the module (which doesn't get abi3 suffix, but is simply called hello_world.pyd when the py_limited_api=True option is set) cannot be imported by different CPython 3.x minor versions.
Dependency Walker says that the .pyd file is linked with PYTHON36.DLL, whereas I would have expected it to be linked with the stable API version of that which is called PYTHON3.DLL.
I came across this issue while debugging another related issue with bdist_wheel --py-limited-api that raises AssertionError on Windows because abi3 tag isn't supported on that platform: hynek/argon2-cffi#32
I was doing #define Py_LIMITED_API when it was too late, i.e. after #include <Python.h>.
Whereas, it must be defined before Python.h is included. That's because the latter in turn includes the pyconfig.h header which on Windows has an MSVC specific compiler directive to link with the correct import library when compiling extension modules and Py_LIMITED_API is defined: #pragma comment(lib,"python3.lib")
If I move the Py_LIMITED_API definition at the top before including the Python.h header, then I can successfully compile an extension module that can be imported by multiple versions of CPython 3.x on Windows.
I tried to write a simple CPython extension module that just prints "hello world" in order to try out the
py_limited_api=True
option of setuptoolsExtension
class.The code can be found here: https://github.com/anthrotype/hello-world-cpython-extension
When I build on macOS or Linux, the generated extension module has
abi3
suffix and can be loaded on different CPython versions (e.g. 3.5 and 3.6).On Windows however, the module (which doesn't get
abi3
suffix, but is simply calledhello_world.pyd
when thepy_limited_api=True
option is set) cannot be imported by different CPython 3.x minor versions.Dependency Walker says that the .pyd file is linked with PYTHON36.DLL, whereas I would have expected it to be linked with the stable API version of that which is called PYTHON3.DLL.
I came across this issue while debugging another related issue with
bdist_wheel --py-limited-api
that raisesAssertionError
on Windows becauseabi3
tag isn't supported on that platform:hynek/argon2-cffi#32
cc @agronholm @dholt @zooba @pfmoore @dstufft @jaraco etc.
The text was updated successfully, but these errors were encountered: