Skip to content

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

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

mweinelt merged 1 commit into
NixOS:stagingfrom
qbisi:python-venv

Conversation

@qbisi

@qbisi qbisi commented Nov 16, 2025 •

Copy link
Copy Markdown
Contributor

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

@winterqt winterqt left a comment •

Copy link
Copy Markdown
Member

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

qbisi commented Nov 16, 2025

Copy link
Copy Markdown
Contributor Author

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

qbisi commented Nov 16, 2025

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
Member

wait for nixpkgs-review.

That’s going to take a while 😓

@qbisi

qbisi commented Nov 16, 2025

Copy link
Copy Markdown
Contributor Author

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

qbisi commented Nov 16, 2025

Copy link
Copy Markdown
Contributor Author

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

@qbisi

qbisi commented Nov 16, 2025

Copy link
Copy Markdown
Contributor Author

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

qbisi commented Nov 16, 2025 •

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
Member

Via staging and staging-25.11.

@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
@nixpkgs-ci

nixpkgs-ci Bot commented Nov 16, 2025

Copy link
Copy Markdown
Contributor

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 done
@adamcstephens adamcstephens mentioned this pull request Nov 17, 2025
1 of 13 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-

lf- commented Nov 28, 2025

Copy link
Copy Markdown
Member

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
Copy Markdown

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

Copy link
Copy Markdown
Member

johnhampton added a commit to johnhampton/nix-config that referenced this pull request Oct 20, 2026
The locked nixpkgs includes NixOS/nixpkgs#462090, which fixes the Darwin fish test failure. Remove the temporary override now that fish builds without it; this also removes the deprecated stdenv.isDarwin evaluation warning.
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build failure: fish on darwin

6 participants