Commit 554ded3e authored by Sviatoslav Sydorenko's avatar Sviatoslav Sydorenko

Simplify `command.easy_install.get_site_dirs`

parent b5fdca1e
...@@ -1371,7 +1371,9 @@ def get_site_dirs(): ...@@ -1371,7 +1371,9 @@ def get_site_dirs():
if sys.exec_prefix != sys.prefix: if sys.exec_prefix != sys.prefix:
prefixes.append(sys.exec_prefix) prefixes.append(sys.exec_prefix)
for prefix in prefixes: for prefix in prefixes:
if prefix: if not prefix:
continue
if sys.platform in ('os2emx', 'riscos'): if sys.platform in ('os2emx', 'riscos'):
sitedirs.append(os.path.join(prefix, "Lib", "site-packages")) sitedirs.append(os.path.join(prefix, "Lib", "site-packages"))
elif os.sep == '/': elif os.sep == '/':
...@@ -1389,13 +1391,19 @@ def get_site_dirs(): ...@@ -1389,13 +1391,19 @@ def get_site_dirs():
prefix, prefix,
os.path.join(prefix, "lib", "site-packages"), os.path.join(prefix, "lib", "site-packages"),
]) ])
if sys.platform == 'darwin': if sys.platform != 'darwin':
continue
# for framework builds *only* we add the standard Apple # for framework builds *only* we add the standard Apple
# locations. Currently only per-user, but /Library and # locations. Currently only per-user, but /Library and
# /Network/Library could be added too # /Network/Library could be added too
if 'Python.framework' in prefix: if 'Python.framework' not in prefix:
continue
home = os.environ.get('HOME') home = os.environ.get('HOME')
if home: if not home:
continue
home_sp = os.path.join( home_sp = os.path.join(
home, home,
'Library', 'Library',
...@@ -1405,17 +1413,14 @@ def get_site_dirs(): ...@@ -1405,17 +1413,14 @@ def get_site_dirs():
) )
sitedirs.append(home_sp) sitedirs.append(home_sp)
lib_paths = get_path('purelib'), get_path('platlib') lib_paths = get_path('purelib'), get_path('platlib')
for site_lib in lib_paths:
if site_lib not in sitedirs: sitedirs.extend(s for s in lib_paths if s not in sitedirs)
sitedirs.append(site_lib)
if site.ENABLE_USER_SITE: if site.ENABLE_USER_SITE:
sitedirs.append(site.USER_SITE) sitedirs.append(site.USER_SITE)
try: with contextlib.suppress(AttributeError):
sitedirs.extend(site.getsitepackages()) sitedirs.extend(site.getsitepackages())
except AttributeError:
pass
sitedirs = list(map(normalize_path, sitedirs)) sitedirs = list(map(normalize_path, sitedirs))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment