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

Try to detect if we are in a virtual environment and change path precedence accordingly #286

Merged
merged 8 commits into from Aug 24, 2022

Conversation

jasongrout
Copy link
Member

We make the assumption that if we are in a virtual environment, we should prioritize the environment-level sys.prefix over the user-level paths. The user can opt out of this behavior by setting JUPYTER_PREFER_ENV_PATH, which takes precedence over our autodetection.

Fixes #283

jasongrout and others added 2 commits August 22, 2022 17:58
…edence accordingly.

We make the assumption that if we are in a virtual environment, we should prioritize the environment-level sys.prefix over the user-level paths. The user can opt out of this behavior by setting JUPYTER_PREFER_ENV_PATH, which takes precedence over our autodetection.

Fixes jupyter#283
@jasongrout
Copy link
Member Author

Of course, several tests fail. @gutow (or anyone else), feel free to take over this if you can.

@gutow
Copy link

gutow commented Aug 23, 2022

I am trying to pick this up. But am having trouble setting up an environment where I can run tests locally.

It looks to me like line 29 of paths.py is causing the error in the CI testing:

def envset(name, default=False):

Should be:

def envset(name, default="no"):

To be consistent with the vocabulary used previously.

I get errors on running the tests that appear to be caused by isolating the tests in a virtual environment. They are not the same as occur in the github CI testing.

So, I think I would have to set up a virtual machine with no virtual environments to do the tests on my local machine. I have lots of different projects on my machine, so have them all isolated in virtual environments. I definitely do not want to set this one up outside of a virtual environment. Am I on the right track here?

…tters.

Now that we have autodetection logic for when we are in a virtual env, we must explicitly set this variable to off if we expect it off.
@jasongrout
Copy link
Member Author

It looks to me like line 29 of paths.py is causing the error in the CI testing:

Actually, most of the errors came from an actual bug in my code. Doh! 8b5f1c5

Copy link
Member

@blink1073 blink1073 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@blink1073 blink1073 merged commit 2976226 into jupyter:main Aug 24, 2022
@gutow
Copy link

gutow commented Aug 24, 2022

Thanks you for this change. I look forward to the next release. I think this will help avoid problems for naive user such as myself.

@blink1073 blink1073 added this to the 5.0 milestone Nov 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make JUPYTER_PREFER_ENV_PATH=1 default
3 participants