Does anyone have python-env patch binary-cached for aarch64-darwin?

For a context:

this issue python3.withPackages: python wrapper doesn't load generated env on x86_64-linux (emulated on darwin with rosetta) · Issue #461884 · NixOS/nixpkgs · GitHub is killer of Python envs and affects current master and current nixpkgs-unstable (checked out today).

its scope is broader and Darwin is also affected.

Apart from wondering why it’s not back ported (and assuming there are valid reasons for this),
building the patch is quite painful experience as it wants to bootstrap stdenv:

--- a/pkgs/development/interpreters/python/wrapper.nix	2025-11-28 10:03:04
+++ b/pkgs/development/interpreters/python/wrapper.nix	2025-11-25 16:15:55
@@ -50,6 +50,7 @@
                 if [ "$prg" = "${python.executable}" ]; then
                   makeWrapper "${python.interpreter}" "$out/bin/$prg" \
                     --inherit-argv0 \
+                    --resolve-argv0 \
                     ${lib.optionalString (!permitUserSite) ''--set PYTHONNOUSERSITE "true"''} \
                     ${lib.concatStringsSep " " makeWrapperArgs}
                 elif [ "$(readlink "$prg")" = "${python.executable}" ]; then

a.k.a. python-env: wrap python executable with --resolve-argv0 by qbisi · Pull Request #462090 · NixOS/nixpkgs · GitHub

So, by a chance, maybe has someone already built patched nixpkgs-unstable and cached it for aarch64-darwin?

Meanwhile, patched my shebangs

@@ -1,5 +1,7 @@
-#!/usr/bin/env nix-shell
-#!nix-shell --pure -i python3 -p "python3.withPackages (ps: with ps; [ requests beautifulsoup4])"
+#!/usr/bin/env -S uv run --script
+# /// script
+# dependencies = ["requests", "beautifulsoup4"]
+# ///

The fix is not in unstable yet because it causes a mass rebuild of everything on Darwin. Mass rebuilds are managed via the staging workflow. I believe a final cycle is planned for 25.05 then one for unstable and 25.11. I’d expect the fix to land in unstable sometime in mid-December.

Follow https://nixpkgs-tracker.ocfox.me/?pr=462090 for progress updates.

1 Like