python: implement PEP 668 (#229166)
Add a marker file to the python outputs that tells pip and other tooling following PEP 668 that they should not be installing things system-wide. This provides better feedback to the user and also potentially avoids issues in single-user installs where the /nix/store is owned by the user. For more details, see <https://peps.python.org/pep-0668/> Here is how it currently looks like: $ pip install requests error: externally-managed-environment × This environment is externally managed ╰─> This command has been disabled as it tries to modify the immutable `/nix/store` filesystem. To use Python with Nix and nixpkgs, have a look at the online documentation: <https://nixos.org/manual/nixpkgs/stable/#python>.
This commit is contained in:
@@ -486,6 +486,16 @@ in with passthru; stdenv.mkDerivation {
|
||||
# bytecode compilations for the same reason - we don't want bytecode generated.
|
||||
mkdir -p $out/share/gdb
|
||||
sed '/^#!/d' Tools/gdb/libpython.py > $out/share/gdb/libpython.py
|
||||
|
||||
# Disable system-wide pip installation. See https://peps.python.org/pep-0668/.
|
||||
cat <<'EXTERNALLY_MANAGED' > $out/lib/${libPrefix}/EXTERNALLY-MANAGED
|
||||
[externally-managed]
|
||||
Error=This command has been disabled as it tries to modify the immutable
|
||||
`/nix/store` filesystem.
|
||||
|
||||
To use Python with Nix and nixpkgs, have a look at the online documentation:
|
||||
<https://nixos.org/manual/nixpkgs/stable/#python>.
|
||||
EXTERNALLY_MANAGED
|
||||
'';
|
||||
|
||||
preFixup = lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
|
||||
|
||||
Reference in New Issue
Block a user