@@ -1,7 +1,7 @@
11# Wrapper around wrapPythonProgramsIn, below. The $pythonPath
22# variable is passed in from the buildPythonPackage function.
33wrapPythonPrograms() {
4− wrapPythonProgramsIn $out "$out $pythonPath"
4+ wrapPythonProgramsIn "$out/bin" "$out $pythonPath"
55}
66
77# Builds environment variables like PYTHONPATH and PATH walking through closure
@@ -47,34 +47,36 @@ wrapPythonProgramsIn() {
4747 buildPythonPath "$pythonPath"
4848
4949 # Find all regular files in the output directory that are executable.
50− find "$dir" -type f -perm -0100 -print0 | while read -d "" f; do
51− # Rewrite "#! .../env python" to "#! /nix/store/.../python".
52− # Strip suffix, like "3" or "2.7m" -- we don't have any choice on which
53− # Python to use besides one with this hook anyway.
54− if head -n1 "$f" | grep -q '#!.*/env.*\(python\|pypy\)'; then
55− sed -i "$f" -e "1 s^.*/env[ ]*\(python\|pypy\)[^ ]*^#! @executable@^"
56− fi
50+ if [ -d "$dir" ]; then
51+ find "$dir" -type f -perm -0100 -print0 | while read -d "" f; do
52+ # Rewrite "#! .../env python" to "#! /nix/store/.../python".
53+ # Strip suffix, like "3" or "2.7m" -- we don't have any choice on which
54+ # Python to use besides one with this hook anyway.
55+ if head -n1 "$f" | grep -q '#!.*/env.*\(python\|pypy\)'; then
56+ sed -i "$f" -e "1 s^.*/env[ ]*\(python\|pypy\)[^ ]*^#! @executable@^"
57+ fi
5758
58− # catch /python and /.python-wrapped
59− if head -n1 "$f" | grep -q '/\.\?\(python\|pypy\)'; then
60− # dont wrap EGG-INFO scripts since they are called from python
61− if echo "$f" | grep -qv EGG-INFO/scripts; then
62− echo "wrapping \`$f'..."
63− patchPythonScript "$f"
64− # wrapProgram creates the executable shell script described
65− # above. The script will set PYTHONPATH and PATH variables.!
66− # (see pkgs/build-support/setup-hooks/make-wrapper.sh)
67− local -a wrap_args=("$f"
68− --prefix PATH ':' "$program_PATH")
59+ # catch /python and /.python-wrapped
60+ if head -n1 "$f" | grep -q '/\.\?\(python\|pypy\)'; then
61+ # dont wrap EGG-INFO scripts since they are called from python
62+ if echo "$f" | grep -qv EGG-INFO/scripts; then
63+ echo "wrapping \`$f'..."
64+ patchPythonScript "$f"
65+ # wrapProgram creates the executable shell script described
66+ # above. The script will set PYTHONPATH and PATH variables.!
67+ # (see pkgs/build-support/setup-hooks/make-wrapper.sh)
68+ local -a wrap_args=("$f"
69+ --prefix PATH ':' "$program_PATH")
6970
70− # Add any additional arguments provided by makeWrapperArgs
71− # argument to buildPythonPackage.
72− local -a user_args="($makeWrapperArgs)"
73− local -a wrapProgramArgs=("${wrap_args[@]}" "${user_args[@]}")
74− wrapProgram "${wrapProgramArgs[@]}"
71+ # Add any additional arguments provided by makeWrapperArgs
72+ # argument to buildPythonPackage.
73+ local -a user_args="($makeWrapperArgs)"
74+ local -a wrapProgramArgs=("${wrap_args[@]}" "${user_args[@]}")
75+ wrapProgram "${wrapProgramArgs[@]}"
76+ fi
7577 fi
76− fi
77− done
78+ done
79+ fi
7880}
7981
8082# Adds the lib and bin directories to the PYTHONPATH and PATH variables,