summary refs log tree commit diff
path: root/pkgs/development/interpreters/python/wrap.sh
diff options
context:
space:
mode:
authorFrederik Rietdijk <fridh@fridh.nl>2017-05-24 08:43:07 +0200
committerFrederik Rietdijk <fridh@fridh.nl>2017-05-27 14:25:08 +0200
commitc10af9e744c91dff1ccc07a52a0b57d1e4d339f3 (patch)
tree475da4ec2d049a3c44cc18d673fa59a44e1756e1 /pkgs/development/interpreters/python/wrap.sh
parentdc2250eb5e91ac7591b446e69583d009cac05fbf (diff)
downloadnixpkgs-c10af9e744c91dff1ccc07a52a0b57d1e4d339f3.tar
nixpkgs-c10af9e744c91dff1ccc07a52a0b57d1e4d339f3.tar.gz
nixpkgs-c10af9e744c91dff1ccc07a52a0b57d1e4d339f3.tar.bz2
nixpkgs-c10af9e744c91dff1ccc07a52a0b57d1e4d339f3.tar.lz
nixpkgs-c10af9e744c91dff1ccc07a52a0b57d1e4d339f3.tar.xz
nixpkgs-c10af9e744c91dff1ccc07a52a0b57d1e4d339f3.tar.zst
nixpkgs-c10af9e744c91dff1ccc07a52a0b57d1e4d339f3.zip
Python: wrapPythonPrograms: only wrap in $out/bin
Thus far all executables in a derivation were wrapped. This commit
only wraps executables in $out/bin. If other scripts need to be wrapped
as well, then one can use wrapPythonProgramsIn.
Diffstat (limited to 'pkgs/development/interpreters/python/wrap.sh')
-rw-r--r--pkgs/development/interpreters/python/wrap.sh54
1 files changed, 28 insertions, 26 deletions
diff --git a/pkgs/development/interpreters/python/wrap.sh b/pkgs/development/interpreters/python/wrap.sh
index 55998bc5b41..1c74e612b55 100644
--- a/pkgs/development/interpreters/python/wrap.sh
+++ b/pkgs/development/interpreters/python/wrap.sh
@@ -1,7 +1,7 @@
 # Wrapper around wrapPythonProgramsIn, below. The $pythonPath
 # variable is passed in from the buildPythonPackage function.
 wrapPythonPrograms() {
-    wrapPythonProgramsIn $out "$out $pythonPath"
+    wrapPythonProgramsIn "$out/bin" "$out $pythonPath"
 }
 
 # Builds environment variables like PYTHONPATH and PATH walking through closure
@@ -47,34 +47,36 @@ wrapPythonProgramsIn() {
     buildPythonPath "$pythonPath"
 
     # Find all regular files in the output directory that are executable.
-    find "$dir" -type f -perm -0100 -print0 | while read -d "" f; do
-        # Rewrite "#! .../env python" to "#! /nix/store/.../python".
-        # Strip suffix, like "3" or "2.7m" -- we don't have any choice on which
-        # Python to use besides one with this hook anyway.
-        if head -n1 "$f" | grep -q '#!.*/env.*\(python\|pypy\)'; then
-            sed -i "$f" -e "1 s^.*/env[ ]*\(python\|pypy\)[^ ]*^#! @executable@^"
-        fi
+    if [ -d "$dir" ]; then
+        find "$dir" -type f -perm -0100 -print0 | while read -d "" f; do
+            # Rewrite "#! .../env python" to "#! /nix/store/.../python".
+            # Strip suffix, like "3" or "2.7m" -- we don't have any choice on which
+            # Python to use besides one with this hook anyway.
+            if head -n1 "$f" | grep -q '#!.*/env.*\(python\|pypy\)'; then
+                sed -i "$f" -e "1 s^.*/env[ ]*\(python\|pypy\)[^ ]*^#! @executable@^"
+            fi
 
-        # catch /python and /.python-wrapped
-        if head -n1 "$f" | grep -q '/\.\?\(python\|pypy\)'; then
-            # dont wrap EGG-INFO scripts since they are called from python
-            if echo "$f" | grep -qv EGG-INFO/scripts; then
-                echo "wrapping \`$f'..."
-                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")
+            # catch /python and /.python-wrapped
+            if head -n1 "$f" | grep -q '/\.\?\(python\|pypy\)'; then
+                # dont wrap EGG-INFO scripts since they are called from python
+                if echo "$f" | grep -qv EGG-INFO/scripts; then
+                    echo "wrapping \`$f'..."
+                    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")
 
-                # Add any additional arguments provided by makeWrapperArgs
-                # argument to buildPythonPackage.
-                local -a user_args="($makeWrapperArgs)"
-                local -a wrapProgramArgs=("${wrap_args[@]}" "${user_args[@]}")
-                wrapProgram "${wrapProgramArgs[@]}"
+                    # Add any additional arguments provided by makeWrapperArgs
+                    # argument to buildPythonPackage.
+                    local -a user_args="($makeWrapperArgs)"
+                    local -a wrapProgramArgs=("${wrap_args[@]}" "${user_args[@]}")
+                    wrapProgram "${wrapProgramArgs[@]}"
+                fi
             fi
-        fi
-    done
+        done
+    fi
 }
 
 # Adds the lib and bin directories to the PYTHONPATH and PATH variables,