From f1e679c3fb26bf2a3264ef63b4b207412417521e Mon Sep 17 00:00:00 2001 From: Philipp Richter Date: Sun, 19 Feb 2023 22:42:55 +0000 Subject: Expose a 'decky_plugin' module to decky plugins (#353) * Expose a 'decky_plugin' module to decky plugins * expose decky user home path * support 'py_modules' python modules in plugins * allow for a '_migration' method in plugins to have an explicit file moving step * Expose the plugin python module as .pyi stub interface * Expose system and user python paths to plugins --- backend/helpers.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'backend/helpers.py') diff --git a/backend/helpers.py b/backend/helpers.py index 7cab512b..35681f68 100644 --- a/backend/helpers.py +++ b/backend/helpers.py @@ -115,8 +115,18 @@ def mkdir_as_user(path): # Fetches the version of loader def get_loader_version() -> str: - with open(os.path.join(os.path.dirname(sys.argv[0]), ".loader.version"), "r", encoding="utf-8") as version_file: - return version_file.readline().replace("\n", "") + try: + with open(os.path.join(os.path.dirname(sys.argv[0]), ".loader.version"), "r", encoding="utf-8") as version_file: + return version_file.readline().replace("\n", "") + except: + return "" + +# returns the appropriate system python paths +def get_system_pythonpaths() -> list[str]: + # run as normal normal user to also include user python paths + proc = subprocess.run(["python3", "-c", "import sys; print(':'.join(x for x in sys.path if x))"], + user=get_user_id(), env={}, capture_output=True) + return proc.stdout.decode().strip().split(":") # Download Remote Binaries to local Plugin async def download_remote_binary_to_path(url, binHash, path) -> bool: -- cgit v1.2.3