Files
Alex Kotliarskyi 6e27f7daa2 Avoid installing dependencies on every run
It looks like the `install.py` is imported from `__init__.py`, which means every time this plugin is loaded, it'll trigger a bunch of `pip install`s.
2024-02-27 12:06:30 -08:00

19 lines
549 B
Python

import sys
import os.path
import subprocess
custom_nodes_path = os.path.dirname(os.path.abspath(__file__))
def build_pip_install_cmds(args):
if "python_embeded" in sys.executable or "python_embedded" in sys.executable:
return [sys.executable, '-s', '-m', 'pip', 'install'] + args
else:
return [sys.executable, '-m', 'pip', 'install'] + args
def ensure_package():
cmds = build_pip_install_cmds(['-r', 'requirements.txt'])
subprocess.run(cmds, cwd=custom_nodes_path)
if __name__ == "__main__":
ensure_package()