summaryrefslogtreecommitdiff
path: root/required_modules.py
blob: 06661c53048860e82327fe34fa83d73493dbcb91 (plain)
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
import bpy, sys
from subprocess import run

# get python's binary path (literally my saviour)
py_bin = bpy.app.binary_path_python
upd_mods = ["wheel", "setuptools"]
trusted_hosts = ["--trusted-host", "pypi.python.org", "--trusted-host", "files.pythonhosted.org", "--trusted-host", "pypi.org"]

try:
  import pip
  import lxml
except:
  # hecking install pip (ensurepip) + required modules
  run([py_bin, "-m", "ensurepip"])  
  # update pip, setuptools and pyinstaller to latest version
  run([py_bin, "-m", "pip", "install", "--upgrade", "--force-reinstall", "pip"] + trusted_hosts)  
  run([py_bin, "-m", "pip", "install", "--upgrade"] + upd_mods + trusted_hosts)  
  # install required modules depending on python version
  if (sys.version_info.minor == 5): # blender 2.79b
    run([py_bin, "-m", "pip", "install", "lxml==4.9.3"] + trusted_hosts)
  else: # blender 2.79 latest
    run([py_bin, "-m", "pip", "install", "lxml"] + trusted_hosts)
  print("First exit!")
  exit(0)

# print module's versions installed
print("pip %s is installed!" % (pip.__version__))
print("lxml %s is installed!" % (lxml.__version__))