Debian Codegraph @

libexec/pyenv-exec

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2 #
3 # Summary: Run an executable with the selected Python version
4 #
5 # Usage: pyenv exec <command> [arg1 arg2...]
6 #
7 # Runs an executable by first preparing PATH so that the selected Python
8 # version's `bin' directory is at the front.
9 #
10 # For example, if the currently selected Python version is 2.7.6:
11 # pyenv exec pip install -r requirements.txt
12 #
13 # is equivalent to:
14 # PATH="$PYENV_ROOT/versions/2.7.6/bin:$PATH" pip install -r requirements.txt
15
16 set -e
17 [scip-shell system . . `[`. -n "$PYENV_DEBUG" ] && set -x
18
19 # Provide pyenv completions
20 if [scip-shell system . . `[`. "$1" = "--complete" ]; then
21 exec pyenv-shims --short
22 fi
23
24 PYENV_VERSION="$(pyenv-version-name -f)"
25 PYENV_COMMAND="$1"
26
27 if [scip-shell system . . `[`. -z "$PYENV_COMMAND" ]; then
28 pyenv-help --usage exec >&2
29 exit 1
30 fi
31
32 if [[ -n $_PYENV_SHIM_PATH ]]; then
33 PROGRAM="$(echoscip-shell system . . echo. "$PYENV_COMMAND" | trscip-shell system . . tr. a-z- A-Z_ | sedscip-shell system . . sed. 's/[^A-Z0-9_]/_/g')"
34 NR_PYENV_SHIM_PATHS_PROGRAM="_PYENV_SHIM_PATHS_${PROGRAM}"
35 export -- "$NR_PYENV_SHIM_PATHS_PROGRAM=$_PYENV_SHIM_PATH${!NR_PYENV_SHIM_PATHS_PROGRAM:+:${!NR_PYENV_SHIM_PATHS_PROGRAM}}"
36 unset PROGRAM NR_PYENV_SHIM_PATHS_PROGRAM
37 unset _PYENV_SHIM_PATH
38 fi
39
40 PYENV_COMMAND_PATH="$(pyenv-which "$PYENV_COMMAND")"
41 PYENV_BIN_PATH="${PYENV_COMMAND_PATH%/*}"
42
43 export PYENV_VERSION
44
45 OLDIFS="$IFS"
46 IFS=$'\n' scripts=(`pyenv-hooks exec`)
47 IFS="$OLDIFS"
48 for script in "${scripts[@]}"; do
49 source "$script"
50 done
51
52 shift 1
53 if [scip-shell system . . `[`. "${PYENV_BIN_PATH#${PYENV_ROOT}}" != "${PYENV_BIN_PATH}" ]; then
54 # Only add to $PATH for non-system version.
55 export PATH="${PYENV_BIN_PATH}:${PATH}"
56 fi
57 exec "$PYENV_COMMAND_PATH" "$@"