bpo-29592: site: skip abs_paths() when it's redundant (GH-167)

Call abs_paths() only if removeduppaths() changed sys.path
This commit is contained in:
INADA Naoki 2017-03-15 00:52:19 +09:00 committed by GitHub
parent aa289a59ff
commit 2e4e011795
1 changed files with 6 additions and 1 deletions

View File

@ -522,8 +522,13 @@ def main():
""" """
global ENABLE_USER_SITE global ENABLE_USER_SITE
abs_paths() orig_path = sys.path[:]
known_paths = removeduppaths() known_paths = removeduppaths()
if orig_path != sys.path:
# removeduppaths() might make sys.path absolute.
# fix __file__ and __cached__ of already imported modules too.
abs_paths()
known_paths = venv(known_paths) known_paths = venv(known_paths)
if ENABLE_USER_SITE is None: if ENABLE_USER_SITE is None:
ENABLE_USER_SITE = check_enableusersite() ENABLE_USER_SITE = check_enableusersite()