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

Check if site.getuserbase() exists #247

Merged
merged 1 commit into from
Oct 27, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions jupyter_core/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,13 @@ def jupyter_path(*subdirs):
# Next is environment or user, depending on the JUPYTER_PREFER_ENV_PATH flag
user = [jupyter_data_dir()]
if site.ENABLE_USER_SITE:
userdir = os.path.join(site.getuserbase(), 'share', 'jupyter')
# Check if site.getuserbase() exists to be compatible with virtualenv,
# which often does not have this method.
if hasattr(site, 'getuserbase'):
userbase = site.getuserbase()
else:
userbase = site.USER_BASE
userdir = os.path.join(userbase, 'share', 'jupyter')
if userdir not in user:
user.append(userdir)

Expand Down Expand Up @@ -231,7 +237,14 @@ def jupyter_config_path():
# Next is environment or user, depending on the JUPYTER_PREFER_ENV_PATH flag
user = [jupyter_config_dir()]
if site.ENABLE_USER_SITE:
userdir = os.path.join(site.getuserbase(), 'etc', 'jupyter')
# Check if site.getuserbase() exists to be compatible with virtualenv,
# which often does not have this method.
if hasattr(site, 'getuserbase'):
userbase = site.getuserbase()
else:
userbase = site.USER_BASE

userdir = os.path.join(userbase, 'etc', 'jupyter')
if userdir not in user:
user.append(userdir)

Expand Down