mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-20 04:31:52 +00:00
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
|
||||
# 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
|
||||
|
||||
# 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[@]}"
|
||||
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
|
||||
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,
|
||||
|
|
Loading…
Reference in a new issue