summaryrefslogtreecommitdiff
path: root/required_modules.py
diff options
context:
space:
mode:
authorIsaac <isaclien9752@gmail.com>2024-08-25 09:48:03 -0400
committerIsaac <isaclien9752@gmail.com>2024-08-25 09:48:03 -0400
commit621b80b977b6e89e31e8a3b7c4fd636cff52fb1b (patch)
treea81b95507ead4df6ca7e8ae4bda8e6f157c7ff20 /required_modules.py
parent5297d6b2cca54fab12ed62b96df8207f10f8c02c (diff)
downloadblenxy-621b80b977b6e89e31e8a3b7c4fd636cff52fb1b.tar.gz
blenxy-621b80b977b6e89e31e8a3b7c4fd636cff52fb1b.zip
redo required_modules
Diffstat (limited to 'required_modules.py')
-rw-r--r--required_modules.py47
1 files changed, 19 insertions, 28 deletions
diff --git a/required_modules.py b/required_modules.py
index 98af424..6049839 100644
--- a/required_modules.py
+++ b/required_modules.py
@@ -1,36 +1,27 @@
-# I tried...
+import bpy
+from subprocess import run
+
+# get python's binary path (literally my saviour)
+py_bin = bpy.app.binary_path_python
+req_mods = ["lxml"]
+trusted_hosts = ["--trusted-host", "pypi.python.org", "--trusted-host", "files.pythonhosted.org", "--trusted-host", "pypi.org"]
-# setup pip with ensurepip if it isn't included
try:
import pip
+ import setuptools
+ import lxml
except:
- import ensurepip
- ensurepip.bootstrap()
+ # hecking install pip (ensurepip) + required modules
+ run([py_bin, "-m", "ensurepip"])
+ # update pip and setuptools to latest version
+ run([py_bin, "-m", "pip", "install", "--upgrade", "--force-reinstall", "pip"] + trusted_hosts)
+ run([py_bin, "-m", "pip", "install", "--upgrade", "setuptools"] + trusted_hosts)
+ # install required modules
+ run([py_bin, "-m", "pip", "install"] + req_mods + trusted_hosts)
print("First exit!")
- exit(0)
+ exit(0)
-# upgrade pip (check the version installed by ensurepip)
-if (int(pip.__version__.split('.')[0]) > 9):
- from pip._internal import main
-else:
- from pip import main
-
-# 24.0 is the last version for python3.7
-import certifi
-if (int(pip.__version__.split('.')[0]) < 24):
- main(["install", "--cert", str(certifi.where()), "--upgrade", "--force-reinstall", "pip", "-q"])
- print("Second exit!")
- exit(0)
-import pip
+# print module's versions installed
print("pip %s is installed!" % (pip.__version__))
-
-# check if lxml is installed
-try:
- import lxml
-except:
- main(["install", "lxml"])
- print("Third exit!")
- exit(0)
+print("setuptools %s is installed!" % (pip.__version__))
print("lxml %s is installed!" % (lxml.__version__))
-
-# no more exits please...