Skip to content

Commit 6ae163c

Browse files
committed
pass custom paths e.g. user paths to the pip subprocess
now pip list also shows packages installed to e.g. the addons folder
1 parent c8d814c commit 6ae163c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import subprocess
1919
import bpy
2020
from pathlib import Path
21+
import os
2122

2223
MODULES_FOLDER = Path(bpy.utils.user_resource("SCRIPTS")) / "modules"
2324

@@ -37,6 +38,14 @@ def run_pip_command(self, *cmds, cols=False, run_module="pip"):
3738

3839
cmds = [c for c in cmds if c is not None]
3940

41+
# combine all entries in os.path with path separator
42+
joined_paths = os.pathsep.join(sys.path)
43+
env_var = os.environ.get("PYTHONPATH")
44+
if env_var:
45+
os.environ["PYTHONPATH"] = f"{env_var}{os.pathsep}{joined_paths}"
46+
else:
47+
os.environ["PYTHONPATH"] = joined_paths
48+
4049
# TODO: make this function only run pip commands, make separate function to run other modules
4150
# Choose where to save Python modules
4251
# if bpy.context.scene.pip_modules_home and MODULES_FOLDER.exists() and run_module == "pip":

0 commit comments

Comments
 (0)