CAD_Sketcher icon indicating copy to clipboard operation
CAD_Sketcher copied to clipboard

Use USERBASE based package installation into local directory

Open laundmo opened this issue 3 years ago • 5 comments

This PR sets and uses USERBASE for pip installations. This has the advantage of never interacting with the systems python installation and should prevent bugs which might happend due to wrong versions of pip (shimmed by conda)

This also localises the dependencies within the addons folder to make sure permission errors don't happen.

This is after i deletd both py-slvs and pip from any python packages directories blender can see, and clicking the "install from pip" button once: image

closes: #243

also i formatted the files i touched with black, which is in line with #248 so i hope its fine even before that is closed.

TODO:

  • [] test how well this works with .whl installation

laundmo avatar Aug 13 '22 18:08 laundmo

This did work on my end and installed the module into CAD_Sketcher/lib/python3.10/site-packages. For some reason it cannot find the module in the same session, i had to restart blender. Also this added a bin folder which should also be ignored by git.

I'll have to add those, the folder names depend on what Python does for different OSs so we have to gitignore all versions - i forgot it only uses the Python3x folder scheme on windows. Maybe it's better to add another folder to USERBASE so that we can gitignore that without caring about OS specifics.

As for the finding the module: I'm not sure why that's failing - I'll have to boot into my linux install to test. wierd.

laundmo avatar Aug 14 '22 14:08 laundmo

Well path and user_base seems to be right: sys.path: ['/home/yoga/Dropbox/blend/addons/CAD_Sketcher/lib/python3.10/site-packages', '/usr/share/blender/3.2/scripts/startup', '/usr/share/blender/3.2/scripts/modules', '/usr/lib/python310.zip', '/usr/lib/python3.10', '/usr/lib/python3.10/lib-dynload', '/usr/lib/python3.10/site-packages', '/usr/share/blender/3.2/scripts/freestyle/modules', '/usr/share/blender/3.2/scripts/addons/modules', '/home/yoga/.config/blender/3.2/scripts/addons/modules', '/usr/share/blender/3.2/scripts/addons', '/home/yoga/.config/blender/3.2/scripts/addons', '/home/yoga/Dropbox/blend/addons', '/usr/share/blender/3.2/scripts/addons_contrib']

site.USER_BASE: /home/yoga/Dropbox/blend/addons/CAD_Sketcher

hlorus avatar Aug 15 '22 15:08 hlorus

Calling importlib.invalidate_caches seems to do the trick on my end.

hlorus avatar Aug 15 '22 15:08 hlorus

The Linux issues here are fairly interesting, and indeed need to be solved ; thankfully I'm on Linux too, but I'll need someone to take a look at my fixed version later on other platforms, to make sure I didn't break anything. :-)

Cheaterman avatar Feb 14 '23 12:02 Cheaterman

The linux issue might be py_slv 1.0.5 wheel package's problem. https://github.com/realthunder/slvs_py/issues/7 somehow, this specific version installs module files into wrong location. The 1.0.3 wheel version works fine even without this pr.

alexfanqi avatar Mar 16 '23 11:03 alexfanqi