-
Notifications
You must be signed in to change notification settings - Fork 470
Description
it would be nice to not need to recompile jsonnet for each new python version and instead rely on an abi3 wheel
I believe enabling this isn't too terribly difficult -- essentially following the pattern in this setup.py here: https://github.com/anthonywritescode/explains/blob/c81e7d3c8335daa70c696a04d7c6621932ba1cdf/sample_code/ep135/rev04/setup.py (sample code from my video on the subject)
and an additional carve-out for free threaded python: https://github.com/asottile/ukkonen/blob/5fa9858f0997927d9f9c1794e1741fe8dbd4c1e8/setup.py#L11 (which doesn't support limited api)
and adjusting the c sources to only use functions in the limited api
after that you'd only need to build a single wheel per (platform, architecture) rather than a wheel for each (python, platform, architecture) -- and that wheel would continue to work when new python versions are released. for example for ukkonen above the cp310-abi3 wheels work on any newer python version (matching that platform) without needing to recompile
in the C sources there's not too many things to update it seems:
PyUnicode_AsUTF8->PyUnicode_AsUTF8AndSize(in stable api as of python 3.10)PySequence_Fast_GET_SIZE->PySequence_Size(in stable api)PySequence_Fast_GET_ITEM->PySequence_GetItem(in stable api)
the one downside in this case is the GET_SIZE / GET_ITEM "functions" are macros and converting them to function calls has ever-so-slight overhead (though likely near zero in this particular case -- and depending on link time optimizations might actually be zero)
related / unrelated -- does the jsonnet build still support python 2 ? I see ifdefs for it in the c sources that might be able to be simplified at the same time