Closed matthew-brett closed 2 years ago
Is there anything I should be doing to help?
You can replace assert_equal(x, y)
with assert x == y
then Pytest will tell you what the variables were in its error message in Python 3.
@HexDecimal - thanks - that is helpful. Would you consider doing a review?
Could to try adding define_macros=[("CYTHON_LIMITED_API", "0x03060000"), ("Py_LIMITED_API", "0x03060000")]
to the Extension
classes in the test wheels in order to enable the Stable ABI? This should set a consistent name for the extension file no matter which version of Python 3 is used to compile it.
You could then append --py-limited-api=cp36
to the setup.py
commands of wheels with extensions so that the wheels are given the same names and can be run from any later version of Python 3.
Thanks - nice idea. Trying this now though, it does set the wheel name to e.g.:
fakepkg1-1.0-cp36-abi3-macosx_10_9_universal2.whl
but the extension filenames in the wheel stay the same:
fakepkg/subpkg/module2.cpython-39-darwin.so
Is that what you were expecting?
--py-limited-api
assumes the extensions are correct and module2.cpython-39-darwin.so
is wrong as long as it still has cpython-39
in it.
I can only assume that Cython is having trouble with using the stable ABI. This is something that could be put off until a later PR.
I've seen a suggestion to add py_limited_api=True
to Extension
, maybe could affect it?
It could also be that the setup scripts are using distutils
instead of setuptools
.
I think distutils
is most likely the issue. from setuptools import setup, Extension
should be used instead.
Doesn't seem to make any difference to the file extension - any of the suggestions and various other things I tried... If you have any other suggestions, happy to try them.
I looked into it more. It's an experimental feature that's in the pre-release versions of Cython. With the latest pre-release I couldn't get a local test to build.
An option is to use an alternative to Cython. I have experience with cffi
which I know to work. Also a plain C extension might be possible since the example is simple. These things can be done in a later PR, since it's gotten pretty far from how easy I initially thought this would be.
OK - I switched to using the bare Python C-API - that does work for the limited API.
Good job. The extensions end with abi3.so
now, which is what I would've expected.
I think it's ready now; tests should be passing, the limited API is definitely an improvement.
I think it looks fine. I can't follow the code as well without type hints so my review is mostly just me glancing at the code.
Rebuild wheel examples and libraries on Big Sur.
Adapt code to
universal2
dual arch builds, andarm64
as second architecture, instead ofi386
.Refactor to allow for Big Sur's push of system libraries into a dynamic linker cache, so the libraries are no longer on the file system.