-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetenv
More file actions
26 lines (22 loc) · 1.13 KB
/
setenv
File metadata and controls
26 lines (22 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env -S sh -c "echo >&2 \"Error: You are running this script instead of sourcing it. Make sure to use it as 'source setenv' or '. setenv', otherwise its settings won't take effect.\"; exit 1"
# Resolve the path of this script whether it was sourced from bash or zsh.
# Under bash, BASH_SOURCE[0] is the sourced file; under zsh, %x expands to it.
if [ -n "$BASH_VERSION" ]; then
_OPP_REPL_SETENV_FILE="${BASH_SOURCE[0]}"
elif [ -n "$ZSH_VERSION" ]; then
_OPP_REPL_SETENV_FILE="${(%):-%x}"
else
_OPP_REPL_SETENV_FILE="$0"
fi
export OPP_REPL_ROOT="$(cd "$(dirname "$_OPP_REPL_SETENV_FILE")" && pwd)"
unset _OPP_REPL_SETENV_FILE
# If the user installed opp_repl into a sibling virtual environment
# (e.g. `python3 -m venv .venv && .venv/bin/pip install -e .`), activate
# it automatically so `opp_repl` and its dependencies are available
# without a second `source` step.
if [ -f "$OPP_REPL_ROOT/.venv/bin/activate" ]; then
. "$OPP_REPL_ROOT/.venv/bin/activate"
fi
export PATH="$OPP_REPL_ROOT/bin:$OPP_REPL_ROOT/opp_repl:$PATH"
export PYTHONPATH="$OPP_REPL_ROOT:$PYTHONPATH"
echo "opp_repl is ready (added $OPP_REPL_ROOT to PATH)."