Skip to content

Commit

Permalink
setup_pytest to find site-packages folder near sys.executable
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
Andrej730 committed Oct 30, 2023
1 parent 01b5f8f commit a7712a9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/blenderbim/scripts/setup_pytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down

0 comments on commit a7712a9

Please sign in to comment.