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 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}"])