Skip to content

Commit

Permalink
support both modules paths
Browse files Browse the repository at this point in the history
  • Loading branch information
hannesdelbeke authored Nov 20, 2023
1 parent 50e40b2 commit b091fc4
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


user_scripts_path = Path(bpy.utils.script_path_user())
pth_path = user_scripts_path / "addons/modules"
pth_paths = [user_scripts_path / "modules", user_scripts_path / "addons/modules"]
startup_path = user_scripts_path / "startup"


Expand All @@ -28,7 +28,7 @@ def create_pth_startup_file(): # startup_path, pth_path
pth_path: the path to add to site packages on startup
"""
global startup_path
global pth_path
global pth_paths
# startup_path = Path(startup_path)
startup_path.mkdir(parents=True, exist_ok=True) # startup folder might not exist
file_path = startup_path / "blender_pth_startup.py"
Expand All @@ -39,12 +39,14 @@ def create_pth_startup_file(): # startup_path, pth_path
with open(file_path, "w") as f:
text = "# this file was generated by the blender_pip addon\n" \
"# it enables support for editable pip installs to the modules folder\n" \
f"site.addsitedir(r'{pth_path}')\n" \
"import site\n"
"import site\n" \
f"site.addsitedir(r'{pth_paths[0]}')\n" \
f"site.addsitedir(r'{pth_paths[1]}')\n"
f.write(text)

import site
site.addsitedir(pth_path)
for pth_path in pth_paths:
site.addsitedir(pth_path)


class PipQtPreferences(bpy.types.AddonPreferences):
Expand All @@ -67,7 +69,7 @@ def execute(self, context):

import pip_qt

pip_qt.py_pip.default_target_path = pth_path # todo remove reference of py pip in this module
pip_qt.py_pip.default_target_path = pth_paths[0] # todo remove reference of py pip in this module
window = pip_qt.show()

return {'FINISHED'}
Expand Down

0 comments on commit b091fc4

Please sign in to comment.