heroweb/myenv.sh

38 lines
1.2 KiB
Bash
Raw Permalink Normal View History

2024-09-09 03:56:44 +00:00
#!/bin/bash
2024-09-05 04:56:55 +00:00
SCRIPT_PATH="${BASH_SOURCE[0]:-$0}"
export BASE_DIR="$(cd "$(dirname "$SCRIPT_PATH")" && pwd)"
2024-08-22 10:09:10 +00:00
export VENV_DIR="${BASE_DIR}/.venv"
python3 -m venv "$VENV_DIR"
source $VENV_DIR/bin/activate
# Check if the directory exists
if [ ! -d "$VENV_DIR" ]; then
echo "Directory $VENV_DIR does not exist. Creating it and setting up a virtual environment."
# The -p flag makes mkdir create any necessary parent directories as well
mkdir -p "$VENV_DIR"
# Create the virtual environment
python3 -m venv "$VENV_DIR"
python3 -m pip install --upgrade pip
fi
2024-09-09 03:56:44 +00:00
export CONTEXTROOT='~/context'
SECRET_FILE="/${HOME}/code/git.ourworld.tf/despiegk/hero_secrets/mysecrets.sh"
if [ -f "$SECRET_FILE" ]; then
echo 'get secrets'
source "$SECRET_FILE"
fi
2024-09-14 03:59:42 +00:00
PYTHON_VERSION=$(python3 -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")
WEBLIB_PATH="${VENV_DIR}/lib/python${PYTHON_VERSION}/site-packages/weblib.pth"
HEROLIB_PATH="${VENV_DIR}/lib/python${PYTHON_VERSION}/site-packages/herolib.pth"
if [ ! -f "$WEBLIB_PATH" ] || [ ! -f "$HEROLIB_PATH" ]; then
echo "One or both of the required .pth files are missing. Running install.sh."
source "${BASE_DIR}/install.sh"
fi
2024-09-09 03:56:44 +00:00
echo "We're good to go"