home · contact · privacy
Avoid unnecessary pip install runs. master
authorChristian Heller <c.heller@plomlompom.de>
Sat, 8 Feb 2025 17:49:03 +0000 (18:49 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Sat, 8 Feb 2025 17:49:03 +0000 (18:49 +0100)
src/run.py
ytplom

index 49214ce2fb66cb4e4ef73dca2333ef3fdf1f5c51..c94838c617fb643f6557b63fdf1bb3d5ede8b700 100755 (executable)
@@ -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 9bea676fc193da484ad590b204e3d8c28f60c3f0..a79767cca66e6eb094aafecf228b506ada9b43db 100755 (executable)
--- 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" $@