Merge pull request #51641 from codedownio/nousersite-master

Allow skipping the use of the PYTHONNOUSERSITE variable
This commit is contained in:
Frederik Rietdijk 2019-05-13 12:39:25 +02:00 committed by GitHub
commit d801204fdd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 2 deletions

View File

@ -49,6 +49,9 @@
# Skip wrapping of python programs altogether
, dontWrapPythonPrograms ? false
# Skip setting the PYTHONNOUSERSITE environment variable in wrapped programs
, permitUserSite ? false
# Remove bytecode from bin folder.
# When a Python script has the extension `.py`, bytecode is generated
# Typically, executables in bin have no extension, so no bytecode is generated.

View File

@ -73,9 +73,12 @@ wrapPythonProgramsIn() {
# (see pkgs/build-support/setup-hooks/make-wrapper.sh)
local -a wrap_args=("$f"
--prefix PATH ':' "$program_PATH"
--set PYTHONNOUSERSITE "true"
)
if [ -z "$permitUserSite" ]; then
wrap_args+=(--set PYTHONNOUSERSITE "true")
fi
# Add any additional arguments provided by makeWrapperArgs
# argument to buildPythonPackage.
local -a user_args="($makeWrapperArgs)"

View File

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