bpo-45582: Port getpath[p].c to Python (GH-29041)

The getpath.py file is frozen at build time and executed as code over a namespace. It is never imported, nor is it meant to be importable or reusable. However, it should be easier to read, modify, and patch than the previous code.

This commit attempts to preserve every previously tested quirk, but these may be changed in the future to better align platforms.
This commit is contained in:
Steve Dower 2021-12-03 00:08:42 +00:00 committed by GitHub
parent 9f2f7e4226
commit 99fcf15052
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
40 changed files with 3686 additions and 3838 deletions

View file

@ -361,11 +361,11 @@ def getsitepackages(prefixes=None):
continue
seen.add(prefix)
libdirs = [sys.platlibdir]
if sys.platlibdir != "lib":
libdirs.append("lib")
if os.sep == '/':
libdirs = [sys.platlibdir]
if sys.platlibdir != "lib":
libdirs.append("lib")
for libdir in libdirs:
path = os.path.join(prefix, libdir,
"python%d.%d" % sys.version_info[:2],
@ -373,10 +373,7 @@ def getsitepackages(prefixes=None):
sitepackages.append(path)
else:
sitepackages.append(prefix)
for libdir in libdirs:
path = os.path.join(prefix, libdir, "site-packages")
sitepackages.append(path)
sitepackages.append(os.path.join(prefix, "Lib", "site-packages"))
return sitepackages
def addsitepackages(known_paths, prefixes=None):