WHL: enable Limited API-compliant (abi3) wheels#511
WHL: enable Limited API-compliant (abi3) wheels#511neutrinoceros wants to merge 4 commits intopydata:masterfrom
Conversation
1d42e33 to
3d4da82
Compare
|
This appears to work as expected in CI. |
3d4da82 to
bee468d
Compare
That's the way I'm setting it up for PyWavelets too, and is generally the right strategy I believe. For distros for example, they always only compile for a single Python version, so there are no upsides to using the Stable ABI. Same for end users building from source. Wheel distribution is kinda the odd exception. |
|
Can you post the benchmark results? |
bee468d to
1c7f371
Compare
|
Ah, there are already lost to my terminal history unfortunately, but making abi3 an opt-in was trivial enough |
| @@ -1,5 +1,6 @@ | |||
| // Copyright 2010-2019 Keith Goodman | |||
| // Copyright 2019 Bottleneck Developers | |||
| #include <stdlib.h> | |||
There was a problem hiding this comment.
this is needed for malloc and free. I suppose we got away without this include so far because Python.h must include it already, but only conditionally ?
|
opening for review now. The last commit is temporary and intended to be trimmed before merge, but it helps seeing relevant CI in action |
1c7f371 to
a8feebd
Compare
|
I reran the benchmarks (this time on linux + x86_64) master: this branch: |
|
not sure any of these diffs are significant, but I think it's still worth making abi3 an opt-in so we can grow this space without worrying about maximising performance. I expect this will come in handy later this year when/if some version of abi3 makes it into Python 3.15t (see PEPs 803 and 809) |
It's pretty hard to tell, using I'll do a quick pass on review now. |
rgommers
left a comment
There was a problem hiding this comment.
The opt-in approach here looks good to me. The Stable ABI is typically irrelevant for distros as well as end users building from source, so opt-in seems better as the default in general.
A couple of initial comments.
setup.py
Outdated
There was a problem hiding this comment.
This should not be necessary, NPY_TARGET_VERSION isn't useful to use except for targeting newer API than the default.
There was a problem hiding this comment.
good call, I'll remove this
|
|
||
| define_macros = [ | ||
| # keep in sync with runtime requirements (pyproject.toml) | ||
| ("NPY_NO_DEPRECATED_API", "NPY_1_21_API_VERSION"), |
There was a problem hiding this comment.
Centralizing NPY_NO_DEPRECATED_API seems like a useful refactoring either way indeed.
| USE_PY_LIMITED_API = os.getenv( | ||
| "BN_LIMITED_API", "0" | ||
| ) == "1" and not sysconfig.get_config_var("Py_GIL_DISABLED") | ||
| ABI3_TARGET_VERSION = "".join(str(_) for _ in sys.version_info[:2]) |
There was a problem hiding this comment.
This doesn't look quite right, I think we should always target the lowest-supported Python version, rather than the version that's running the build. Or do you plan to enforce (via code comment?) to handle this in the CI workflow file?
There was a problem hiding this comment.
The problem is that when targeting a version that's older than the running interpreter, there are no guarantees that the resulting binaries will actually be backward compatible. Luckily, because cibuildwheel already runs targets in increasing Python version order, this approach works perfectly: the first (oldest) Python builds a wheel and runs tests, then all the other skip the build step and only check for forward compat by running tests.
There was a problem hiding this comment.
a8feebd to
b497e4c
Compare
I initially just wanted to experiment with this and see how far from a working state we were... turns out the existing code is pretty close already, so only a couple tweaks were needed.
PyTuple_GET_*functions are normally faster, as they skip certain checks that equivalent Limited API functions will run, so there could be a case to be made that we should still use them by default, but I'm not convinced that the impact is even measurable (I'll run the benchmarks to double check before I undraft though).