Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pip utils #4577

Merged
merged 2 commits into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions node_scripts/SNLite_templates/templates/pip_install_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions utils/pip_utils.py
Original file line number Diff line number Diff line change
@@ -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}"])