Skip to content

Commit 966e096

Browse files
committed
lib.pypa: Use passthru.pythonABITags
Which was added to nixpkgs in NixOS/nixpkgs#445140 Fixes correctness for ABI compatibility checks with free threaded Python.
1 parent f6381d4 commit 966e096

File tree

1 file changed

+31
-28
lines changed

1 file changed

+31
-28
lines changed

lib/pypa.nix

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -216,35 +216,38 @@ lib.fix (self: {
216216
# Python interpreter derivation
217217
python:
218218
let
219-
inherit (python.passthru) sourceVersion implementation pythonVersion;
220-
221-
# TODO: Implement ABI tags in the nixpkgs Python derivation.
222-
#
223-
# This isn't strictly correct in the face of things like Python free-threading
224-
# which has a `t` suffix but there is no way right now to introspect & check
225-
# if the GIL is enabled or not.
226-
#
227-
# So a free-threaded build will erroneously be returned as compatible with
228-
# regular CPython wheels.
229219
abiTags =
230-
if implementation == "cpython" then
231-
[
232-
"none"
233-
"any"
234-
"abi3"
235-
"cp${sourceVersion.major}${sourceVersion.minor}"
236-
]
237-
else if implementation == "pypy" then
238-
[
239-
"none"
240-
"any"
241-
"pypy${concatStrings (take 2 (splitString "." pythonVersion))}_pp${sourceVersion.major}${sourceVersion.minor}"
242-
]
243-
else
244-
[
245-
"none"
246-
"any"
247-
];
220+
python.passthru.pythonABITags or (
221+
# Fall back to computing an ABI tag.
222+
#
223+
# This isn't strictly correct in the face of things like Python free-threading
224+
# which has a `t` suffix but there is no way right now to introspect & check
225+
# if the GIL is enabled or not.
226+
#
227+
# So a free-threaded build will erroneously be returned as compatible with
228+
# regular CPython wheels.
229+
let
230+
inherit (python.passthru) sourceVersion implementation pythonVersion;
231+
in
232+
if implementation == "cpython" then
233+
[
234+
"none"
235+
"any"
236+
"abi3"
237+
"cp${sourceVersion.major}${sourceVersion.minor}"
238+
]
239+
else if implementation == "pypy" then
240+
[
241+
"none"
242+
"any"
243+
"pypy${concatStrings (take 2 (splitString "." pythonVersion))}_pp${sourceVersion.major}${sourceVersion.minor}"
244+
]
245+
else
246+
[
247+
"none"
248+
"any"
249+
]
250+
);
248251
in
249252
tag: elem tag abiTags;
250253

0 commit comments

Comments
 (0)