From a7712a923fcfc08e88fd7b293c59b410156a15ac Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Mon, 30 Oct 2023 15:12:36 +0500 Subject: [PATCH] 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). --- src/blenderbim/scripts/setup_pytest.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/blenderbim/scripts/setup_pytest.py b/src/blenderbim/scripts/setup_pytest.py index 8bfad2dfb0..f8b1c9f571 100644 --- a/src/blenderbim/scripts/setup_pytest.py +++ b/src/blenderbim/scripts/setup_pytest.py @@ -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"])