-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pre-commit: prevent propagating inputs and polluting user's PYTHONPATH #235123
pre-commit: prevent propagating inputs and polluting user's PYTHONPATH #235123
Conversation
Fixes a bug where pre-commit would pollute the PYTHONPATH with its dependencies, potentially interfering with the user's dependencies.
This seems like a problem with the python hooks. In @FRidh what do you think? |
This issue has come up so unbelievably many times.
I don't want to go into this part entirely here, because it's complex, and possible solutions have been described, but it goes much wider than just Python. This work-around, removing the propagation in case of applications, is acceptable and we do it more often. This is also why we have a separate (IMO |
Add setuptools to virtualenv dependency of pre-commit. Adding pre-commit as a propagatedBuildInput of pre-commit directly doesn't work since propagation is disabled for pre-commit NixOS#235123 Python3.12 no longer ships with distutils. Setuptools package continues to provide distutils. https://docs.python.org/3/whatsnew/3.12.html Many pre-commit jobs require distutils to function.
Description of changes
This prevents pre-commit's dependences from clobbering the user's dependencies via the PYTHONPATH variable in a nix-shell.
Fixes: #223275
Things done
Tested by changing which input is commented in this
flake.nix
:Before:
After:
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)