-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathactivate.sh
More file actions
executable file
·57 lines (50 loc) · 2.13 KB
/
activate.sh
File metadata and controls
executable file
·57 lines (50 loc) · 2.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env bash
# Source this file to activate the project environment.
# Generated by venvman - https://github.com/cshenry/EnvironmentManager
# Get the directory containing this script
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Check for VIRTUAL_ENVIRONMENT_DIRECTORY
if [ -z "${VIRTUAL_ENVIRONMENT_DIRECTORY:-}" ]; then
echo "Error: VIRTUAL_ENVIRONMENT_DIRECTORY is not set." >&2
echo "" >&2
echo "This environment variable must point to your virtual environments root directory." >&2
echo "Use venvman to set it:" >&2
echo " venvman setenv /path/to/your/VirtualEnvironments" >&2
echo "" >&2
echo "Then restart your shell or run: source ~/.bash_profile (or ~/.bashrc)" >&2
return 1 2>/dev/null || exit 1
fi
VENV_SUBDIR="kbu.nb-adp1notebooks-py3.10"
VENV_PATH="${VIRTUAL_ENVIRONMENT_DIRECTORY}/${VENV_SUBDIR}"
if [ ! -f "$VENV_PATH/bin/activate" ]; then
echo "Error: $VENV_PATH/bin/activate not found." >&2
echo "Was the virtual environment created? Check that VIRTUAL_ENVIRONMENT_DIRECTORY is correct." >&2
return 1 2>/dev/null || exit 1
fi
# shellcheck disable=SC1090
source "$VENV_PATH/bin/activate"
echo "Activated $VENV_PATH"
# Handle dependencies.yaml if present
DEPS_FILE="${SCRIPT_DIR}/dependencies.yaml"
if [ -f "$DEPS_FILE" ]; then
# Extract paths from dependencies.yaml and add to PYTHONPATH
# Parse YAML path: lines using grep and sed
grep -E '^[[:space:]]*path:' "$DEPS_FILE" | while IFS= read -r line; do
# Extract the value after "path:"
dep_path=$(echo "$line" | sed 's/^[[:space:]]*path:[[:space:]]*//' | sed 's/^["'"'"']//' | sed 's/["'"'"']$//' | sed 's/[[:space:]]*$//')
if [ -n "$dep_path" ]; then
# If path is relative (doesn't start with /), prepend SCRIPT_DIR
if [[ "$dep_path" != /* ]]; then
dep_path="${SCRIPT_DIR}/${dep_path}"
fi
# Resolve to absolute path
if [ -d "$dep_path" ]; then
dep_path="$(cd "$dep_path" && pwd)"
export PYTHONPATH="${PYTHONPATH:+$PYTHONPATH:}$dep_path"
echo "Added to PYTHONPATH: $dep_path"
else
echo "Warning: Dependency path not found: $dep_path" >&2
fi
fi
done
fi