-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenv.sh
More file actions
executable file
·33 lines (28 loc) · 930 Bytes
/
env.sh
File metadata and controls
executable file
·33 lines (28 loc) · 930 Bytes
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
27
28
29
30
31
32
33
#!/bin/bash
# This script automatically adds the python directory to PYTHONPATH
# Usage: source python-env.sh
# Get the directory where this script is located
# Check ZSH / BASH
if [[ -n "$BASH_VERSION" ]]; then
SCRIPT_PATH="${BASH_SOURCE[0]}"
elif [[ -n "$ZSH_VERSION" ]]; then
SCRIPT_PATH="$0"
else
SCRIPT_PATH="$0"
fi
SCRIPT_DIR="$(cd "$(dirname "${SCRIPT_PATH}")" && pwd)"
# Add the python directory to PYTHONPATH
PYTHON_DIR="${SCRIPT_DIR}/python"
# Check if PYTHONPATH already contains our directory
if [[ ":$PYTHONPATH:" != *":${PYTHON_DIR}:"* ]]; then
# Add to PYTHONPATH without trailing colon
if [[ -z "$PYTHONPATH" ]]; then
export PYTHONPATH="${PYTHON_DIR}"
else
export PYTHONPATH="${PYTHON_DIR}:${PYTHONPATH}"
fi
echo "PYTHONPATH updated to include: ${PYTHON_DIR}"
else
echo "PYTHONPATH already includes: ${PYTHON_DIR}"
fi
echo "Current PYTHONPATH: $PYTHONPATH"