Support debug CPython ABI tags in environment compatibility#18739
Support debug CPython ABI tags in environment compatibility#18739mjansche wants to merge 2 commits intoastral-sh:mainfrom
Conversation
f03126e to
e7ab19a
Compare
|
We shouldn't need to track whether an interpreter is debug, debug and regular interpreters are ABI-compatible (https://docs.python.org/3.10/using/configure.html#python-debug-build):
You shouldn't need the debug flag anymore, it's the same ABI. Can you share the specific problem you had? |
|
Makes sense, but in that case we need to relax some of the installation checks. Here is how the problem currently manifests. Let's say we have a trivial sdist of a native module: Map this into a docker container running So far so good. However, the next step fails: If we dig into it, we see that the wheel build succeeds, but the install fails: |
|
Can you file an issue with what you wrote above? This looks like we should fix it, but with a slightly different fix. I'm also a bit surprised that setuptools still emits the |
|
Done. #18769 |
afb4364 to
bde8b35
Compare
I thought about this and the ABI compatibility. I suspect that some mechanism -- not necessarily the present one -- is still going to be needed. The reason is that debug wheels should probably have higher priority when installing for debug CPython. Concretely, across existing tools (
The other combination (debug wheel and release Python) is not expected to work. When multiple wheel flavors are present, the debug wheel is preferred when installing for debug Python. We can approach this in multiple ways, but I don't see an immediate way of carrying around the information that a given wheel is a debug wheel, so that it can be preferred when installing for debug Python and rejected for release Python. I've pushed a new version to illustrate what I mean. If there's a simpler way, I'm all ears. |
bde8b35 to
30dbdff
Compare
Since CPython 3.8, debug and release builds share the same ABI. A debug interpreter now generates both the debug ABI tag (e.g. cp314d) and the non-debug tag (cp314) as compatible, with the debug tag taking priority. This matches the behavior of pip's packaging library. Non-debug interpreters are unchanged: they do not accept cp314d wheels.
30dbdff to
408b527
Compare
|
It seems like the CPython docs are misleading: python/cpython#146925 I'll review with the clarified CPython compatibility. |
|
That makes sense and is compatible with the tentative conclusion I reached as I was trying this. So a debug CPython can install either a debug wheel or a release wheel. Other tooling (pip & friends) seems to strongly suggest that debug wheels are preferred when installing for a debug Python and when both debug wheels and release wheels are available. I looked for a spec that would say that precisely, but no luck yet. But this is how plain old pip behaves and that behavior also makes intuitive sense. If we want to follow that here, we need some mechanism to track and match the properties of the wheels and the target environment. |
|
There's no spec for the precedence for wheel tags, but generally tools prefer more specific wheel tags over more generic wheel tags and get the same priorities this way, so debug tags over regular tags like pip and friends makes a lot of sense. |
Summary
This PR fixes a problem in
uv pip install, which currently refuses to install debug wheels in virtual environments with debug CPythons.Before this change, wheel parsing already preserved debug ABI suffixes like cp313d and cp314d, but Tags::from_env only propagated free-threaded and legacy pymalloc variants. As a result, uv would detect a debug interpreter correctly during discovery while still generating cp313/cp314 environment tags, causing debug-built wheels to be rejected as incompatible.
Fix this by accepting a debug_enabled flag in Tags::from_env, mapping it to CPythonAbiVariants::Debug, and passing the interpreter debug state from the production call sites in uv-python and uv pip resolution.
Also update the affected tests and helpers, and add a regression test that verifies debug CPython 3.13 generates cp313-cp313d manylinux tags.
Test Plan
Tests run: