From 229c2aa079b1740961fe4a06005e1dd548db02e5 Mon Sep 17 00:00:00 2001 From: Luis Finke Date: Thu, 5 Jan 2023 18:37:38 -0500 Subject: [PATCH] Add simple support for dependent python modules (#11) * add pipinstall script and append py_modules to PYTHONPATH allows dependent python modules to be installed * separate build_frontend and pip_install * use prepare script for installing python modules * use pip3 instead of pip * always create requirements.txt, even if empty --- .gitignore | 1 + main.py | 5 +++++ package.json | 1 + 3 files changed, 7 insertions(+) diff --git a/.gitignore b/.gitignore index 17a9665..8c1ac75 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,7 @@ coverage # Dependency directory node_modules bower_components +py_modules # Editors .idea diff --git a/main.py b/main.py index c0ec3ff..0d28f1a 100644 --- a/main.py +++ b/main.py @@ -1,3 +1,8 @@ +import os +import sys +# append py_modules to PYTHONPATH +sys.path.append(os.path.dirname(os.path.realpath(__file__))+"/py_modules") + import logging logging.basicConfig(filename="/tmp/template.log", diff --git a/package.json b/package.json index a5263a1..432483e 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "0.0.1", "description": "A template to quickly create decky plugins from scratch, based on TypeScript and webpack", "scripts": { + "prepare": "touch requirements.txt && pip3 install --upgrade -r requirements.txt -t py_modules", "build": "shx rm -rf dist && rollup -c", "watch": "rollup -c -w", "test": "echo \"Error: no test specified\" && exit 1"