-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathblender_setup.py
47 lines (37 loc) · 1.08 KB
/
blender_setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import subprocess
import sys
from pathlib import Path
import setuptools
try:
import bpy
except ImportError:
print(
"Module 'bpy' could not be imported. This probably means you are not using Blender to run this script."
)
sys.exit(1)
# OS independent (Windows: bin\python.exe; Mac/Linux: bin/python3.7m)
py_path = Path(sys.prefix) / "bin"
print(py_path)
# first file that starts with "python" in "bin" dir
py_exec = next(py_path.glob("python*"))
# ensure pip is installed & update
print(py_exec)
subprocess.call([str(py_exec), "-m", "ensurepip"])
subprocess.call([str(py_exec), "-m", "pip", "install", "--upgrade", "pip"])
# install dependencies using pip
# dependencies such as 'numpy' could be added to the end of this command's list
packages = ["matplotlib", "scipy", "tqdm"]
for p in packages:
subprocess.call(
[
str(py_exec),
"-m",
"pip",
"install",
"--trusted-host",
"pypi.python.org",
"--trusted-host",
"files.pythonhosted.org",
p,
]
)