mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-07-06 17:13:24 -05:00
python3: include ABI debug suffix d in executable (fixes FT+debug)
When instantiating an environment with the Python interpreter built
with both free threading (aka. without GIL) and `pydebug`, the value
of `passthru.executable` doesn't match any installed file. This was
noticed when building CI pipelines that require the Python interpreter
built with both debug features and free threading.
The cause is that `executable` was built from `libPrefix`, which only
tracks the `t` suffix from `--without-gil` and not the `d` suffix from
`--with-pydebug`. `libPrefix` doubles as the stdlib install directory,
and cpython deliberately shares that directory between debug and
non-debug builds of a given version, so the `d` is intentionally
absent there.
This slipped through because cpython only ever installs a
`python$VERSION -> python$LDVERSION` symlink (e.g. `python3.13 ->
python3.13d`). For debug-only builds the old code happened to ask for
`python3.13`, which is that symlink, so it worked by accident. For
FT+debug, `libPrefix` is `python3.13t`, but cpython installs no such
file; only `python3.13` (symlink) and `python3.13td` (binary).
Fix: append `d` to `executable` (and to the `cp<ver>` wheel ABI tag in
`pythonABITags`) when `enableDebug` is true.
Reproducer for the problem as a bash script:
```bash
set -euo pipefail
nixpkgs="${1:-<nixpkgs>}" # Either custom path if provided, or just <nixpkgs>
read -r -d '' expr <<EOF || true
let
pkgs = import ${nixpkgs} { };
py = pkgs.python313FreeThreading.override {
enableDebug = true;
self = py;
pythonAttr = "python313FreeThreading";
};
in py
EOF
executable=$(nix-instantiate --eval --json --expr "($expr).executable" | tr -d '"')
echo "passthru.executable = ${executable}"
out=$(nix-build --no-out-link --expr "$expr")
echo "store path: ${out}"
if [[ -e "${out}/bin/${executable}" ]]; then
echo "result: OK (binary exists)"
exit 0
fi
echo "result: FAIL (${out}/bin/${executable} not found)"
echo "actually installed:"
ls "${out}/bin/" | grep '^python3\.' | sed 's/^/ /'
exit 1
```
(cherry picked from commit fa6a2e8f1f)
This commit is contained in:
parent
6218be7281
commit
21f3c36499
1 changed files with 3 additions and 2 deletions
|
|
@ -202,6 +202,7 @@ let
|
|||
in
|
||||
python;
|
||||
pythonVersion = with sourceVersion; "${major}.${minor}";
|
||||
abiFlags = lib.optionalString (!enableGIL) "t" + lib.optionalString enableDebug "d";
|
||||
libPrefix = "python${pythonVersion}${lib.optionalString (!enableGIL) "t"}";
|
||||
in
|
||||
passthruFun {
|
||||
|
|
@ -213,7 +214,7 @@ let
|
|||
pythonVersion
|
||||
;
|
||||
implementation = "cpython";
|
||||
executable = libPrefix;
|
||||
executable = "python${pythonVersion}${abiFlags}";
|
||||
sitePackages = "lib/${libPrefix}/site-packages";
|
||||
inherit hasDistutilsCxxPatch pythonAttr;
|
||||
inherit (splices)
|
||||
|
|
@ -227,7 +228,7 @@ let
|
|||
pythonABITags = [
|
||||
"abi3"
|
||||
"none"
|
||||
"cp${sourceVersion.major}${sourceVersion.minor}${lib.optionalString (!enableGIL) "t"}"
|
||||
"cp${sourceVersion.major}${sourceVersion.minor}${abiFlags}"
|
||||
];
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue