summaryrefslogtreecommitdiff
path: root/required_modules.py
blob: fe5ded3990a4691e1b0b6f2ddd6b1a16c3d9647e (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
29
import bpy
from subprocess import run

# get python's binary path (literally my saviour)
py_bin = bpy.app.binary_path_python
pip_install = [py_bin, "-B", "-m", "pip", "install",
               "--trusted-host", "pypi.python.org",
               "--trusted-host", "files.pythonhosted.org",
               "--trusted-host", "pypi.org",
               "-U", "--force-reinstall", "--only-binary", ":all:"]
upd_mods = ["pip", "wheel", "setuptools"]
new_mods = ["lxml"]

try:
  import pip
  import lxml
except:
  # hecking install pip (ensurepip) + required modules
  run([py_bin, "-B", "-m", "ensurepip"])  
  # update basic modules then download new modules
  run(pip_install + upd_mods)
  run(pip_install + new_mods)
  print("First exit!")
  bpy.ops.wm.quit_blender()
  exit(0)

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