Skip to content

Commit

Permalink
Start: Add shell script
Browse files Browse the repository at this point in the history
Same as the batch file. Also edit the python script to work when
a venv is clean.

Signed-off-by: kingbri <[email protected]>
  • Loading branch information
bdashore3 committed Dec 28, 2023
1 parent ac0d6f8 commit ee84d89
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
7 changes: 4 additions & 3 deletions start.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import os
import pathlib
import subprocess
from main import entrypoint


def get_requirements_file():
Expand Down Expand Up @@ -44,7 +43,7 @@ def get_argparser():


if __name__ == "__main__":
subprocess.run("pip -V")
subprocess.run(["pip", "-V"])

parser = get_argparser()
args = parser.parse_args()
Expand All @@ -55,6 +54,8 @@ def get_argparser():
requirements_file = (
"requirements-nowheel" if args.nowheel else get_requirements_file()
)
subprocess.run(f"pip install -U -r {requirements_file}.txt")
subprocess.run(["pip", "install", "-U", "-r", f"{requirements_file}.txt"])

# Import entrypoint after installing all requirements
from main import entrypoint
entrypoint()
22 changes: 18 additions & 4 deletions start.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
#!/bin/bash
cd "$(dirname "$0")"
source ./venv/bin/activate
pip -V
python main.py

cd "$(dirname "$0")" || exit

if [ -n "$CONDA_PREFIX" ]; then
echo "It looks like you're in a conda environment. Skipping venv check."
else
if [ ! -d "venv" ]; then
echo "Venv doesn't exist! Creating one for you."
python3 -m venv venv
fi

echo "Activating venv"

# shellcheck source=/dev/null
source venv/bin/activate
fi

python3 start.py "$@"

0 comments on commit ee84d89

Please sign in to comment.