| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -124,7 +124,7 @@ def removeduppaths(): | |
| # if they only differ in case); turn relative paths into absolute | ||
| # paths. | ||
| dir, dircase = makepath(dir) | ||
| if not dircase in known_paths: | ||
| if dircase not in known_paths: | ||
| L.append(dir) | ||
| known_paths.add(dircase) | ||
| sys.path[:] = L | ||
| Expand Down Expand Up | @@ -234,6 +234,27 @@ def check_enableusersite(): | |
|
|
||
| return True | ||
|
|
||
|
|
||
| def _getuserbase(): | ||
| # Stripped version of sysconfig._getuserbase() | ||
| env_base = os.environ.get("PYTHONUSERBASE", None) | ||
| if env_base: | ||
| return env_base | ||
|
|
||
| def joinuser(*args): | ||
| return os.path.expanduser(os.path.join(*args)) | ||
|
|
||
| if os.name == "nt": | ||
| base = os.environ.get("APPDATA") or "~" | ||
| return joinuser(base, "Python") | ||
|
|
||
| if sys.platform == "darwin" and sys._framework: | ||
| return joinuser("~", "Library", sys._framework, | ||
| "%d.%d" % sys.version_info[:2]) | ||
|
|
||
| return joinuser("~", ".local") | ||
|
|
||
|
|
||
| def getuserbase(): | ||
| """Returns the `user base` directory path. | ||
|
|
||
| Expand All | @@ -242,33 +263,36 @@ def getuserbase(): | |
| it. | ||
| """ | ||
| global USER_BASE | ||
| if USER_BASE is not None: | ||
| return USER_BASE | ||
| from sysconfig import get_config_var | ||
| USER_BASE = get_config_var('userbase') | ||
| if USER_BASE is None: | ||
| USER_BASE = _getuserbase() | ||
| return USER_BASE | ||
|
|
||
|
|
||
| def _get_path(userbase): | ||
| # stripped version of sysconfig.get_path('purelib', os.name + '_user') | ||
|
Comment thread
Outdated
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityAgain, please elaborate the comment. (Maybe point to _getuserbase() above?)
Sorry, something went wrong.
All reactions
|
||
| version = sys.version_info[:2] | ||
|
Comment thread
Outdated
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityIs [:2] really needed?
Sorry, something went wrong.
All reactions
|
||
|
|
||
| if os.name == 'nt': | ||
| return f'{userbase}/Python{version[0]}{version[1]}/site-packages' | ||
|
|
||
| if sys.platform == 'darwin' and sys._framework: | ||
| return f'{userbase}/lib/python/site-packages' | ||
|
|
||
| return f'{userbase}/lib/python{version[0]}.{version[1]}/site-packages' | ||
|
|
||
|
|
||
| def getusersitepackages(): | ||
| """Returns the user-specific site-packages directory path. | ||
|
|
||
| If the global variable ``USER_SITE`` is not initialized yet, this | ||
| function will also set it. | ||
| """ | ||
| global USER_SITE | ||
| user_base = getuserbase() # this will also set USER_BASE | ||
|
|
||
| if USER_SITE is not None: | ||
| return USER_SITE | ||
|
|
||
| from sysconfig import get_path | ||
| userbase = getuserbase() # this will also set USER_BASE | ||
|
|
||
| if sys.platform == 'darwin': | ||
| from sysconfig import get_config_var | ||
| if get_config_var('PYTHONFRAMEWORK'): | ||
| USER_SITE = get_path('purelib', 'osx_framework_user') | ||
| return USER_SITE | ||
| if USER_SITE is None: | ||
| USER_SITE = _get_path(userbase) | ||
|
|
||
| USER_SITE = get_path('purelib', '%s_user' % os.name) | ||
| return USER_SITE | ||
|
|
||
| def addusersitepackages(known_paths): | ||
| Expand Down | ||
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityCan you please elaborate this comment? Please explain that the function was duplicated to speedup Python startup and avoid the sysconfig import in the site module. Add a reference to the bpo 29585.
It seems like you modified this change: you moved "if env_base: return env_base" at the top. Please modify also sysconfig._getuserbase(). I would also prefer the sysconfig also uses sys._framework, instead of get_config_var("PYTHONFRAMEWORK").
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.