dss-extensions / DSS-Python

Native, "direct" Python bindings (interface) and misc tools for a custom implementation of OpenDSS (EPRI Distribution System Simulator). Based on CFFI, DSS C-API, aiming for full COM API-level compatibility on Windows, Linux and MacOS, while providing various extensions.
https://dss-extensions.org/DSS-Python/
BSD 3-Clause "New" or "Revised" License
58 stars 4 forks source link

Use Py_LIMITED_API #24

Closed PMeira closed 2 years ago

PMeira commented 4 years ago

Py_LIMITED_API would allow building a single DLL/shared object compatible with multiple Python versions, since Python 3.2.

Depends on #19.

PMeira commented 4 years ago

It's probably worth waiting for advances in the new HPy efforts instead: https://github.com/pyhandle/hpy/

PMeira commented 3 years ago

Related: https://cffi.readthedocs.io/en/latest/whatsnew.html#v1-14-2

PMeira commented 3 years ago

It worked great on Windows using CFFI 1.14.4:

python setup.py bdist_wheel --py-limited-api cp35

This will simplify packaging. Instead of 25 packages (5 platforms, 5 Python versions), we would only need 5.

Cython still doesn't fully support Py_LIMITED_API. Maybe v3.0 (not yet released) will include everything we need: https://cython.readthedocs.io/en/latest/src/changes.html

It's a good idea to test this for the next release.

PMeira commented 3 years ago

Cython 3.0 or the Py_LIMITED_API implementation is not done yet. The milestone is here: https://github.com/cython/cython/milestone/58

PMeira commented 2 years ago

Since we're testing support for 7 platforms, --py-limited-api cp36 added in https://github.com/dss-extensions/dss_python/commit/9c4479ecef43042f8e0fa13e995e9ab60140ab06 to simplify both the build process and future maintenance/compatibility (Py_LIMITED_API is already used by CFFI). Without this, we would need at least 35 wheels to cover Python 3.6 to 3.10.

Cython will be handled later when it is actually used here.