Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Cad-Sketcher dependency install process might install to user site-packages instead of blender - missing PYTHONUSERSITE in install scripts. #243

Open
laundmo opened this issue Aug 9, 2022 · 4 comments · May be fixed by #249
Labels
Bounty - Small https://www.cadsketcher.com/cad-sketcher-bounty-board bug Something isn't working
Milestone

Comments

@laundmo
Copy link

laundmo commented Aug 9, 2022

Contact Details

laundmo#7544 on discord

Description

When installing the py-slvs package from within the addon, the wrong pip will be called.

Explanation of why this might happen, and correct code to install dependencies:
https://github.com/robertguetzkow/blender-python-examples/tree/master/add_ons/install_dependencies#installing-the-package

The simple fix to this is to modify the environment variables with which pip commands are run.

This blender console script shows the issue:

>>> import sys
>>> sys.executable
'C:\\Program Files\\Blender Foundation\\Blender 3.2\\3.2\\python\\bin\\python.EXE'

>>> import subprocess
>>> subprocess.check_output([sys.executable, "-m", "pip", "-V"])
b'pip 22.2 from C:\\Users\\laundmo\\AppData\\Roaming\\Python\\Python310\\site-packages\\pip (python 3.10)\r\r\n'

as you can see, this found the wrong pip (from my appdata site-packages)

heres a minimal version of the fix in action:

>>> import os
>>> environ_copy = dict(os.environ)
>>> environ_copy["PYTHONNOUSERSITE"] = "1"
>>> subprocess.check_output([sys.executable, "-m", "pip", "-V"], env=environ_copy)
b'pip 21.2.4 from C:\\Program Files\\Blender Foundation\\Blender 3.2\\3.2\\python\\lib\\site-packages\\pip (python 3.10)\r\r\n'

Addon Version

latest

Blender Version

all

What platform are you running on?

Windows

@laundmo laundmo added the bug Something isn't working label Aug 9, 2022
@laundmo
Copy link
Author

laundmo commented Aug 9, 2022

I'm open to making a PR for this myself over the next weekend - i'd just like a go-ahead first.

@amrsoll
Copy link
Collaborator

amrsoll commented Aug 9, 2022

oh wow, good catch, that could also explain some "breakages" for people with multiple blender versions and so on...

Anywhere the PYPATH variable is used in the codebase would be affected.

@laundmo
Copy link
Author

laundmo commented Aug 9, 2022

Aye, stumbled across this on the Discord server where a user was having issues with the install proceess using condas pip which doesn't work at all outside of a conda environment. Its potentially huge to the install process breaking.

@hlorus
Copy link
Owner

hlorus commented Aug 9, 2022

If you could submit a PR that would be great obviously.

@hlorus hlorus added this to the 1.0 Release milestone Feb 13, 2023
@hlorus hlorus added the Bounty - Small https://www.cadsketcher.com/cad-sketcher-bounty-board label Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bounty - Small https://www.cadsketcher.com/cad-sketcher-bounty-board bug Something isn't working
Projects
Development

Successfully merging a pull request may close this issue.

3 participants