setup_pytest to find site-packages folder near sys.executable

Used to get errors running setup_pytest.py having python 3.10 installed on my pc (`sys_paths[-1]` was the system's python folder, not the blender's python).
This commit is contained in:
Andrej730
2023-10-30 15:12:36 +05:00
parent 01b5f8f237
commit a7712a923f
+3 -1
View File
@@ -18,18 +18,20 @@
import sys
import subprocess
from pathlib import Path
print("Here are the detected system paths:")
print(sys.path)
py_exec = str(sys.executable)
base_python_path = str(Path(sys.executable).parent.parent) # path without bin/python.exe
print("Detected executable:", py_exec)
subprocess.call([py_exec, "-m", "ensurepip", "--user"])
subprocess.call([py_exec, "-m", "pip", "install", "--upgrade", "pip"])
sys_paths = [p for p in sys.path if "site-packages" in p]
sys_paths = [p for p in sys.path if "site-packages" in p and p.startswith(base_python_path)]
if sys_paths:
print("Detected installation directory:", sys_paths[-1])
subprocess.call([py_exec, "-m", "pip", "install", f"--target={sys_paths[-1]}", "--upgrade", "pytest"])