diff options
author | Nikolay Amiantov <ab@fmap.me> | 2016-08-17 02:51:55 +0300 |
---|---|---|
committer | Nikolay Amiantov <ab@fmap.me> | 2016-08-20 00:42:49 +0300 |
commit | 4ad459e3e0ad7366fa01a4c6592adf14e4edf62c (patch) | |
tree | 859772e427fff2033bc25fa3f54b72740aaa7de5 | |
parent | 01624e1ac29ee0854cb63d0c1efb6d791c1441d4 (diff) | |
download | nixpkgs-4ad459e3e0ad7366fa01a4c6592adf14e4edf62c.tar nixpkgs-4ad459e3e0ad7366fa01a4c6592adf14e4edf62c.tar.gz nixpkgs-4ad459e3e0ad7366fa01a4c6592adf14e4edf62c.tar.bz2 nixpkgs-4ad459e3e0ad7366fa01a4c6592adf14e4edf62c.tar.lz nixpkgs-4ad459e3e0ad7366fa01a4c6592adf14e4edf62c.tar.xz nixpkgs-4ad459e3e0ad7366fa01a4c6592adf14e4edf62c.tar.zst nixpkgs-4ad459e3e0ad7366fa01a4c6592adf14e4edf62c.zip |
wrapPythonProgram: split into several functions
-rw-r--r-- | pkgs/development/python-modules/generic/wrap.sh | 44 |
1 files changed, 30 insertions, 14 deletions
diff --git a/pkgs/development/python-modules/generic/wrap.sh b/pkgs/development/python-modules/generic/wrap.sh index d0c49c36c4b..f4b2d44993c 100644 --- a/pkgs/development/python-modules/generic/wrap.sh +++ b/pkgs/development/python-modules/generic/wrap.sh @@ -4,16 +4,12 @@ wrapPythonPrograms() { wrapPythonProgramsIn $out "$out $pythonPath" } -# Transforms any binaries generated by the setup.py script, replacing them -# with an executable shell script which will set some environment variables -# and then call into the original binary (which has been given a .wrapped -# suffix). -wrapPythonProgramsIn() { - local dir="$1" - local pythonPath="$2" +# Builds environment variables like PYTHONPATH and PATH walking through closure +# of dependencies. +buildPythonPath() { + local pythonPath="$1" local python="@executable@" local path - local f # Create an empty table of python paths (see doc on _addToPythonPath # for how this is used). Build up the program_PATH and program_PYTHONPATH @@ -24,6 +20,30 @@ wrapPythonProgramsIn() { for path in $pythonPath; do _addToPythonPath $path done +} + +# Patches a Python script so that it has correct libraries path and executable +# name. +patchPythonScript() { + local f="$1" + + # The magicalSedExpression will invoke a "$(basename "$f")", so + # if you change $f to something else, be sure to also change it + # in pkgs/top-level/python-packages.nix! + # It also uses $program_PYTHONPATH. + sed -i "$f" -re '@magicalSedExpression@' +} + +# Transforms any binaries generated by the setup.py script, replacing them +# with an executable shell script which will set some environment variables +# and then call into the original binary (which has been given a .wrapped +# suffix). +wrapPythonProgramsIn() { + local dir="$1" + local pythonPath="$2" + local f + + buildPythonPath "$pythonPath" # Find all regular files in the output directory that are executable. for f in $(find "$dir" -type f -perm -0100); do @@ -39,16 +59,12 @@ wrapPythonProgramsIn() { # dont wrap EGG-INFO scripts since they are called from python if echo "$f" | grep -qv EGG-INFO/scripts; then echo "wrapping \`$f'..." - # The magicalSedExpression will invoke a "$(basename "$f")", so - # if you change $f to something else, be sure to also change it - # in pkgs/top-level/python-packages.nix! - # It also uses $program_PYTHONPATH. - sed -i "$f" -re '@magicalSedExpression@' + patchPythonScript "$f" # wrapProgram creates the executable shell script described # above. The script will set PYTHONPATH and PATH variables.! # (see pkgs/build-support/setup-hooks/make-wrapper.sh) local -a wrap_args=("$f" - --prefix PATH ':' "$program_PATH:$dir/bin") + --prefix PATH ':' "$program_PATH") # Add any additional arguments provided by makeWrapperArgs # argument to buildPythonPackage. |