mirror of
https://github.com/theroyallab/tabbyAPI.git
synced 2026-04-26 09:18:53 +00:00
Start: Add shell script
Same as the batch file. Also edit the python script to work when a venv is clean. Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
7
start.py
7
start.py
@@ -3,7 +3,6 @@ import argparse
|
|||||||
import os
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
import subprocess
|
import subprocess
|
||||||
from main import entrypoint
|
|
||||||
|
|
||||||
|
|
||||||
def get_requirements_file():
|
def get_requirements_file():
|
||||||
@@ -44,7 +43,7 @@ def get_argparser():
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
subprocess.run("pip -V")
|
subprocess.run(["pip", "-V"])
|
||||||
|
|
||||||
parser = get_argparser()
|
parser = get_argparser()
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
@@ -55,6 +54,8 @@ if __name__ == "__main__":
|
|||||||
requirements_file = (
|
requirements_file = (
|
||||||
"requirements-nowheel" if args.nowheel else get_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()
|
entrypoint()
|
||||||
|
|||||||
22
start.sh
Normal file → Executable file
22
start.sh
Normal file → Executable file
@@ -1,5 +1,19 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
cd "$(dirname "$0")"
|
|
||||||
source ./venv/bin/activate
|
cd "$(dirname "$0")" || exit
|
||||||
pip -V
|
|
||||||
python main.py
|
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 "$@"
|
||||||
|
|||||||
Reference in New Issue
Block a user