Skip to content

python-env: wrap python executable with --resolve-argv0#462090

Merged
mweinelt merged 1 commit intoNixOS:stagingfrom
qbisi:python-venv
Nov 16, 2025
Merged

python-env: wrap python executable with --resolve-argv0#462090
mweinelt merged 1 commit intoNixOS:stagingfrom
qbisi:python-venv

Conversation

@qbisi
Copy link
Contributor

@qbisi qbisi commented Nov 16, 2025

original pr: #442540

"--resolve-argv0" resolve python's argv[0] to absolute path on darwin platform. This help setting python's prefix correctly on darwin platform when invoking python from PATH. (note on linux platform we dont need "--resolve-argv0")

should fix #461406

Things done

build legacyPackages.aarch64-darwin.fish

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

Add a 👍 reaction to pull requests you find important.

@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 6.topic: python Python is a high-level, general-purpose programming language. labels Nov 16, 2025
@qbisi qbisi changed the base branch from master to staging-next November 16, 2025 01:21
@nixpkgs-ci nixpkgs-ci bot closed this Nov 16, 2025
@nixpkgs-ci nixpkgs-ci bot reopened this Nov 16, 2025
Copy link
Member

@winterqt winterqt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot! I figured it was something in the wrapper, but didn’t dig into it yet.

Could you please add the justification for this to the commit message, so future contributors can see what happened here?

(Furthermore, wondering out loud: why is this only an issue on Darwin?!)

@qbisi
Copy link
Contributor Author

qbisi commented Nov 16, 2025

I am rebuilding the whole darwin world to see if this pr does fix #461406.
For the justfication, i don't know the root cause why darwin handle's path different than linux, maybe we need to dig into cpython's source. But i will add things meaningful to the commit message.

This commit, together with NixOS#442540,
changes the way python environments are built:

  * When generating wrappers for python executables, we inherit argv[0]
    from the wrapper. This causes python to initialize its configuration
    in the environment with all the correct paths.
  * We also resolve argv[0] to absolute path when invoking python from
    PATH. This helps set python's prefix correctly on Darwin.

The end result is that python environments no longer appear to be venvs,
and behave more like a vanilla python installation. In addition it's
possible to create a venv using an environment and use packages from
both the environment and the venv.
@qbisi qbisi marked this pull request as ready for review November 16, 2025 04:56
@qbisi
Copy link
Contributor Author

qbisi commented Nov 16, 2025

tested build fish on local python-venv branch. wait for nixpkgs-review.

@qbisi qbisi requested a review from mweinelt November 16, 2025 04:57
@nixpkgs-ci nixpkgs-ci bot requested a review from natsukium November 16, 2025 05:01
@winterqt
Copy link
Member

wait for nixpkgs-review.

That’s going to take a while 😓

@qbisi
Copy link
Contributor Author

qbisi commented Nov 16, 2025

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 462090 --package fish
Commit: abe61db737b8d682dd632fd60ba071757021d4d6


aarch64-darwin

❌ 2 packages failed to build:
  • fish
  • fish.doc (fish.doc.doc)

@qbisi
Copy link
Contributor Author

qbisi commented Nov 16, 2025

nixpkgs-review failed due to non-reproducible failure of pytest-xdist (will likely to fail with cores > 1)

@qbisi
Copy link
Contributor Author

qbisi commented Nov 16, 2025

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 462090 --package fish
Commit: abe61db737b8d682dd632fd60ba071757021d4d6


aarch64-darwin

✅ 2 packages built:
  • fish
  • fish.doc (fish.doc.doc)

@qbisi
Copy link
Contributor Author

qbisi commented Nov 16, 2025

cc @mweinelt , should we revert 442540 or apply this patch to last staging-next circle.

@qbisi qbisi added the 0.kind: ZHF Fixes Fixes during the Zero Hydra Failures (ZHF) campaign label Nov 16, 2025
@mweinelt
Copy link
Member

Via staging and staging-25.11.

@mweinelt mweinelt added the backport staging-25.11 Backport PR automatically label Nov 16, 2025
@qbisi qbisi changed the base branch from staging-next to staging November 16, 2025 13:31
@nixpkgs-ci nixpkgs-ci bot closed this Nov 16, 2025
@nixpkgs-ci nixpkgs-ci bot reopened this Nov 16, 2025
@mweinelt mweinelt added this pull request to the merge queue Nov 16, 2025
Merged via the queue into NixOS:staging with commit dd11cde Nov 16, 2025
57 of 61 checks passed
@nixpkgs-ci
Copy link
Contributor

nixpkgs-ci bot commented Nov 16, 2025

Successfully created backport PR for staging-25.11:

@github-actions github-actions bot added the 8.has: port to stable This PR already has a backport to the stable release. label Nov 16, 2025
@dixslyf dixslyf mentioned this pull request Nov 17, 2025
3 tasks
cullenmcdermott pushed a commit to cullenmcdermott/nix-config that referenced this pull request Nov 20, 2025
Investigated removing the nixpkgs pin now that fish 4.2.1 test failures
are resolved (PR #462589 disabled checks on darwin as temporary fix while
PR #462090's Python wrapper fixes go through staging).

However, latest nixpkgs-unstable (Nov 20) has a new issue: pyarrow build
failures on darwin due to multiple conflicting protobuf versions (30, 31,
33) in the dependency closure causing memory corruption.

Issue: NixOS/nixpkgs#461396
Pending fixes: PRs #461569, #461572 (still in staging, not merged)

Keeping the Nov 8 pin until the protobuf fixes land in nixpkgs-unstable.
The fish issue won't affect builds since checks are disabled on darwin.

Related: NixOS/nixpkgs#461406 (fish), NixOS/nixpkgs#462090, NixOS/nixpkgs#462589
cullenmcdermott pushed a commit to cullenmcdermott/nix-config that referenced this pull request Nov 20, 2025
Investigated removing the nixpkgs pin now that fish 4.2.1 test failures
are resolved (PR #462589 disabled checks on darwin as temporary fix while
PR #462090's Python wrapper fixes go through staging).

However, latest nixpkgs-unstable (Nov 20) has a new issue: pyarrow build
failures on darwin due to multiple conflicting protobuf versions (30, 31,
33) in the dependency closure causing memory corruption.

Issue: NixOS/nixpkgs#461396
Pending fixes: PRs #461569, #461572 (still in staging, not merged)

Keeping the Nov 8 pin until the protobuf fixes land in nixpkgs-unstable.
The fish issue won't affect builds since checks are disabled on darwin.

Related: NixOS/nixpkgs#461406 (fish), NixOS/nixpkgs#462090, NixOS/nixpkgs#462589
@lf-
Copy link
Member

lf- commented Nov 28, 2025

FYI workaround:
Tracker: https://nixpk.gs/pr-tracker.html?pr=462090

  # https://github.com/NixOS/nixpkgs/pull/462090
  horribleHackToFixPythonWithPackages =
    ppkgs:
    ppkgs.overrideAttrs (oldAttrs: {
      postBuild =
        assert !(lib.hasInfix "--resolve-argv0" oldAttrs.postBuild);
        lib.replaceString "--inherit-argv0" "--inherit-argv0 --resolve-argv0" oldAttrs.postBuild;
    });

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/does-anyone-have-python-env-patch-binary-cached-for-aarch64-darwin/72631/1

lf- added a commit to lf-/dotfiles that referenced this pull request Dec 13, 2025
@phanirithvij
Copy link
Member

https://nixpkgs-tracker.ocfox.me/?pr=462090, #461884 (comment) and #471587 (I can't access nixpk.gs/pr-tracker)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

0.kind: ZHF Fixes Fixes during the Zero Hydra Failures (ZHF) campaign 6.topic: python Python is a high-level, general-purpose programming language. 8.has: port to stable This PR already has a backport to the stable release. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. backport staging-25.11 Backport PR automatically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build failure: fish on darwin

6 participants