Repository navigation
fix: let extraPackages python env win python3 on PATH - #1246
Merged
Merged
Conversation
A pythonXX.withPackages env passed via extraPackages was silently shadowed by vig-utils' propagated pinned 3.14 interpreter, so the consumer got the bare interpreter with none of their libraries. Prepend such envs in the shellHook (the same PATH-order mechanism pythonOverrideHook uses) so the consumer's env owns python3/python. Refs: #1230
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
mkProjectShellconsumers who add Python libraries the documented way — apythonXX.withPackagesenv passed throughextraPackages— silently got thebuilder's bare pinned 3.14 interpreter on
PATHwith none of theirlibraries, surfacing only later as
ModuleNotFoundError. This blocked thecad2gdml onboarding (FreeCAD via
extraPackages).Closes #1230
Root cause
The bug is a
python3PATH race, but not the one the issue's minimal reprosuggested. Reordering
extraPackagesahead of the barepythoninpackages(the issue's suggested fix 1) does not work, and neither does dropping the
bare
python— I verified both live. The interpreter that actually shadows theconsumer's env is
vig-utils: it is abuildPythonPackageindevTools,pinned to 3.14, and its Python setup hook propagates that 3.14 interpreter
onto
PATHahead of anything inpackages. This is the exact same shadowingpythonOverrideHook(flake.nix) already fights for thepython = …overridecase — and it beats it the only reliable way in this builder: a shellHook
PATHprepend.Evidence (before fix,
extraPackages = [ python313.withPackages … ]):Fix
Prepend any
extraPackages-provided Python env in the shellHook (identified byits
pythonpassthru, which awithPackagesenv carries and the bareinterpreter / plain library packages do not), using the same PATH-order
mechanism as
pythonOverrideHook. Placed beforepythonOverrideHookin thechain so an explicit
pythonoverride (the primary interpreter knob, #1038)still wins if a consumer sets both.
packageslist unchanged, so the zero-extraPackagesdefault dev-shell staysbyte-identical (the
#1038parity test still passes).pythonoverride path and#729bare-python3presence are unaffected.Test evidence
New
tests/test_flake_devshell.py::test_devshell_extrapackages_python_env_wins_on_pathbuilds a real
mkProjectShellwith apython313.withPackages([setuptools])envin
extraPackages, enters it undernix develop --ignore-environment, andasserts
python3resolves to the env (3.13) and imports itssetuptools.ModuleNotFoundError: No module named 'setuptools'/python3reports 3.14 — the exact issue reproduction.1 passed.Regression set (all pass):
python_default_is_byte_identical,python_override_switches_interpreter,exposes_python3_and_precommit, plus thenew test —
4 passed.prek run --all-files: fully green.