From 8aeedc64caa02b5467831a1398dde49a822a7605 Mon Sep 17 00:00:00 2001 From: David Date: Mon, 4 Dec 2023 14:03:32 -0800 Subject: [PATCH] install... --- __init__.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/__init__.py b/__init__.py index 186760a..b6df696 100644 --- a/__init__.py +++ b/__init__.py @@ -1,3 +1,24 @@ from .nodes import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS __all__ =["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS"] + +# scavenged install sequence from https://github.com/FizzleDorf/ComfyUI_FizzNodes/blob/main/__init__.py +def is_installed(package, package_overwrite=None): + try: + spec = importlib.util.find_spec(package) + except ModuleNotFoundError: + pass + + package = package_overwrite or package + + if spec is None: + print(f"Installing {package}...") + command = f'"{python}" -m pip install {package}' + + result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, env=os.environ) + + if result.returncode != 0: + print(f"Couldn't install\nCommand: {command}\nError code: {result.returncode}") + +# to do: read from requirements.txt +is_installed("keyframed") \ No newline at end of file