Skip to content

Commit a2edcb6

Browse files
committedMar 19, 2025
chore: add activation script for venv end paths
1 parent cbe6148 commit a2edcb6

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
 

‎scripts/activate.sh

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
# Ensure the script is sourced so that environment changes persist.
4+
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
5+
echo "Error: This script must be sourced. Please run:"
6+
echo " source scripts/activate.sh"
7+
exit 1
8+
fi
9+
10+
# Use the current working directory as the project root.
11+
PROJECT_ROOT=$(pwd)
12+
13+
# Check for the existence of the venv directory.
14+
if [ ! -d "$PROJECT_ROOT/venv" ]; then
15+
echo "Error: 'venv' directory not found in current working directory ($PROJECT_ROOT)."
16+
return 1
17+
fi
18+
19+
# Activate the virtual environment.
20+
if [ -f "$PROJECT_ROOT/venv/bin/activate" ]; then
21+
source "$PROJECT_ROOT/venv/bin/activate"
22+
else
23+
echo "Error: Virtual environment activation script not found at $PROJECT_ROOT/venv/bin/activate"
24+
return 1
25+
fi
26+
27+
# Add the venv site-packages to PYTHONPATH.
28+
VENV_SITE_PACKAGES="$PROJECT_ROOT/venv/lib/python3.10/site-packages"
29+
export PYTHONPATH="$PYTHONPATH:$VENV_SITE_PACKAGES"
30+
31+
echo "Virtual environment activated and PYTHONPATH updated."

0 commit comments

Comments
 (0)
Please sign in to comment.