From 6533a532d6c9499838e8873e120ad56570429c9f Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Sat, 8 Feb 2025 18:49:03 +0100 Subject: [PATCH] Avoid unnecessary pip install runs. --- src/run.py | 17 ++++++++++++----- ytplom | 9 +++++++-- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/run.py b/src/run.py index 49214ce..c94838c 100755 --- a/src/run.py +++ b/src/run.py @@ -4,11 +4,16 @@ # included libs from sys import argv, exit as sys_exit # ourselves -from ytplom.db import DbFile -from ytplom.primitives import HandledException -from ytplom.migrations import MIGRATIONS -from ytplom.http import serve -from ytplom.sync import sync +try: + from ytplom.db import DbFile + from ytplom.primitives import HandledException + from ytplom.migrations import MIGRATIONS + from ytplom.http import serve + from ytplom.sync import sync +except ModuleNotFoundError as e: + print('FAIL: Missing module(s), please run with "install_deps" argument.') + print(e) + sys_exit(1) if __name__ == '__main__': @@ -16,6 +21,8 @@ if __name__ == '__main__': if 2 != len(argv): raise HandledException('Bad number of command arguments.') match argv[1]: + case 'install_deps': + raise HandledException('Should be handled by calling script.') case 'create_db': DbFile.create() case 'migrate_db': diff --git a/ytplom b/ytplom index 9bea676..a79767c 100755 --- a/ytplom +++ b/ytplom @@ -6,7 +6,12 @@ PATH_VENV="${PATH_APP_SHARE}/venv" python3 -m venv "${PATH_VENV}" . "${PATH_VENV}/bin/activate" -echo "Checking dependencies." -pip3 install -r "${PATH_APP_SHARE}/requirements.txt" + +if [ "$1" = "install_deps" ]; then + echo "Checking dependencies." + pip3 install -r "${PATH_APP_SHARE}/requirements.txt" + exit 0 +fi + export PYTHONPATH="${PATH_APP_SHARE}:${PYTHONPATH}" python3 "${PATH_APP_SHARE}/run.py" $@ -- 2.30.2