From a646b2775c184939ccd2a1db19af142b89a89951 Mon Sep 17 00:00:00 2001 From: Dealga McArdle Date: Mon, 18 Jul 2022 13:49:12 +0200 Subject: [PATCH 1/2] add file --- utils/pip_utils.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 utils/pip_utils.py diff --git a/utils/pip_utils.py b/utils/pip_utils.py new file mode 100644 index 0000000000..e26cade490 --- /dev/null +++ b/utils/pip_utils.py @@ -0,0 +1,19 @@ +#pip_utils.py + +# you can pass it a package name, or a list of package names +# you can pass it a local whl location +# +# below are examples of lines that you can execute using these two functions, they will call subprocess +# and install the packages into the current bpython executable's site-packages directory. + +import sys +import os +import subprocess + +def install_package(package): + if not isinstance(package, list): + package = [package] + subprocess.call([os.path.join(sys.prefix, 'bin', 'python.exe'), "-m", "pip", "install", *package]) + +def install_whl(package_path): + subprocess.call([os.path.join(sys.prefix, 'bin', 'python.exe'), "-m", "pip", "install", f"{package_path}"]) From 66670fcdb5bb9cb16071f675e42375d0fda570e6 Mon Sep 17 00:00:00 2001 From: Dealga McArdle Date: Mon, 18 Jul 2022 13:52:02 +0200 Subject: [PATCH 2/2] use pip_utils --- .../templates/pip_install_example.py | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/node_scripts/SNLite_templates/templates/pip_install_example.py b/node_scripts/SNLite_templates/templates/pip_install_example.py index 7b0f70a99c..da8348e62c 100644 --- a/node_scripts/SNLite_templates/templates/pip_install_example.py +++ b/node_scripts/SNLite_templates/templates/pip_install_example.py @@ -13,17 +13,7 @@ # below are examples of lines that you can execute using these two functions, they will call subprocess # and install the packages into the current bpython executable's site-packages directory. -import sys -import os -import subprocess - -def install_package(package): - if not isinstance(package, list): - package = [package] - subprocess.call([os.path.join(sys.prefix, 'bin', 'python.exe'), "-m", "pip", "install", *package]) - -def install_whl(package_path): - subprocess.call([os.path.join(sys.prefix, 'bin', 'python.exe'), "-m", "pip", "install", f"{package_path}"]) +from sverchok.utils.pip_utils import install_package, install_whl #if __name__ == '__main__': # install_package(['--upgrade', 'pip']) # <-- may not be needed