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.
This commit is contained in:
parent
dc2250eb5e
commit
c10af9e744
@ -1,7 +1,7 @@
|
|||||||
# Wrapper around wrapPythonProgramsIn, below. The $pythonPath
|
# Wrapper around wrapPythonProgramsIn, below. The $pythonPath
|
||||||
# variable is passed in from the buildPythonPackage function.
|
# variable is passed in from the buildPythonPackage function.
|
||||||
wrapPythonPrograms() {
|
wrapPythonPrograms() {
|
||||||
wrapPythonProgramsIn $out "$out $pythonPath"
|
wrapPythonProgramsIn "$out/bin" "$out $pythonPath"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Builds environment variables like PYTHONPATH and PATH walking through closure
|
# Builds environment variables like PYTHONPATH and PATH walking through closure
|
||||||
@ -47,34 +47,36 @@ wrapPythonProgramsIn() {
|
|||||||
buildPythonPath "$pythonPath"
|
buildPythonPath "$pythonPath"
|
||||||
|
|
||||||
# Find all regular files in the output directory that are executable.
|
# Find all regular files in the output directory that are executable.
|
||||||
find "$dir" -type f -perm -0100 -print0 | while read -d "" f; do
|
if [ -d "$dir" ]; then
|
||||||
# Rewrite "#! .../env python" to "#! /nix/store/.../python".
|
find "$dir" -type f -perm -0100 -print0 | while read -d "" f; do
|
||||||
# Strip suffix, like "3" or "2.7m" -- we don't have any choice on which
|
# Rewrite "#! .../env python" to "#! /nix/store/.../python".
|
||||||
# Python to use besides one with this hook anyway.
|
# Strip suffix, like "3" or "2.7m" -- we don't have any choice on which
|
||||||
if head -n1 "$f" | grep -q '#!.*/env.*\(python\|pypy\)'; then
|
# Python to use besides one with this hook anyway.
|
||||||
sed -i "$f" -e "1 s^.*/env[ ]*\(python\|pypy\)[^ ]*^#! @executable@^"
|
if head -n1 "$f" | grep -q '#!.*/env.*\(python\|pypy\)'; then
|
||||||
fi
|
sed -i "$f" -e "1 s^.*/env[ ]*\(python\|pypy\)[^ ]*^#! @executable@^"
|
||||||
|
|
||||||
# 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[@]}"
|
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
done
|
# 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[@]}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Adds the lib and bin directories to the PYTHONPATH and PATH variables,
|
# Adds the lib and bin directories to the PYTHONPATH and PATH variables,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user