Skip to content

Commit

Permalink
Merge pull request #247 from jasongrout/virtualenv
Browse files Browse the repository at this point in the history
Check if site.getuserbase() exists
  • Loading branch information
Steven Silvester committed Oct 27, 2021
2 parents 9aee793 + 067a230 commit be863e3
Showing 1 changed file with 15 additions and 2 deletions.
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

0 comments on commit be863e3

Please sign in to comment.