diff --git a/pkgs/development/interpreters/python/mk-python-derivation.nix b/pkgs/development/interpreters/python/mk-python-derivation.nix index 46ba7765cdcc..065c10f771e6 100644 --- a/pkgs/development/interpreters/python/mk-python-derivation.nix +++ b/pkgs/development/interpreters/python/mk-python-derivation.nix @@ -47,7 +47,7 @@ , dontWrapPythonPrograms ? false # Skip setting the PYTHONNOUSERSITE environment variable in wrapped programs -, skipNoUserSite ? false +, permitUserSite ? false # Remove bytecode from bin folder. # When a Python script has the extension `.py`, bytecode is generated @@ -96,7 +96,6 @@ let self = toPythonModule (python.stdenv.mkDerivation (builtins.removeAttrs attr installCheckInputs = checkInputs; postFixup = lib.optionalString (!dontWrapPythonPrograms) '' - ${if skipNoUserSite then "export SKIPNOUSERSITE=1" else ""} wrapPythonPrograms '' + lib.optionalString removeBinBytecode '' if [ -d "$out/bin" ]; then diff --git a/pkgs/development/interpreters/python/wrap.sh b/pkgs/development/interpreters/python/wrap.sh index d779826cf81a..c7201c7a997b 100644 --- a/pkgs/development/interpreters/python/wrap.sh +++ b/pkgs/development/interpreters/python/wrap.sh @@ -75,7 +75,7 @@ wrapPythonProgramsIn() { --prefix PATH ':' "$program_PATH" ) - if [ -z "$SKIPNOUSERSITE" ]; then + if [ -z "$permitUserSite" ]; then wrap_args+=(--set PYTHONNOUSERSITE "true") fi diff --git a/pkgs/development/interpreters/python/wrapper.nix b/pkgs/development/interpreters/python/wrapper.nix index 27d01e4e1f51..5a2ec567b9eb 100644 --- a/pkgs/development/interpreters/python/wrapper.nix +++ b/pkgs/development/interpreters/python/wrapper.nix @@ -3,6 +3,7 @@ , extraOutputsToInstall ? [] , postBuild ? "" , ignoreCollisions ? false +, permitUserSite ? false , requiredPythonModules # Wrap executables with the given argument. , makeWrapperArgs ? [] @@ -34,7 +35,7 @@ let if [ -f "$prg" ]; then rm -f "$out/bin/$prg" if [ -x "$prg" ]; then - makeWrapper "$path/bin/$prg" "$out/bin/$prg" --set PYTHONHOME "$out" --set PYTHONNOUSERSITE "true" ${stdenv.lib.concatStringsSep " " makeWrapperArgs} + makeWrapper "$path/bin/$prg" "$out/bin/$prg" --set PYTHONHOME "$out" ${if permitUserSite then "" else ''--set PYTHONNOUSERSITE "true"''} ${stdenv.lib.concatStringsSep " " makeWrapperArgs} fi fi done