bpo-31904: Fix site and sysconfig modules for VxWorks RTOS (GH-21821)

This commit is contained in:
pxinwr 2020-12-21 06:27:42 +08:00 committed by GitHub
parent c95f8bc270
commit ab74c014ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 113 additions and 72 deletions

View file

@ -264,6 +264,10 @@ def _getuserbase():
if env_base:
return env_base
# VxWorks has no home directories
if sys.platform == "vxworks":
return None
def joinuser(*args):
return os.path.expanduser(os.path.join(*args))
@ -311,11 +315,14 @@ def getusersitepackages():
If the global variable ``USER_SITE`` is not initialized yet, this
function will also set it.
"""
global USER_SITE
global USER_SITE, ENABLE_USER_SITE
userbase = getuserbase() # this will also set USER_BASE
if USER_SITE is None:
USER_SITE = _get_path(userbase)
if userbase is None:
ENABLE_USER_SITE = False # disable user site and return None
else:
USER_SITE = _get_path(userbase)
return USER_SITE
@ -630,11 +637,14 @@ def _script():
for dir in sys.path:
print(" %r," % (dir,))
print("]")
print("USER_BASE: %r (%s)" % (user_base,
"exists" if os.path.isdir(user_base) else "doesn't exist"))
print("USER_SITE: %r (%s)" % (user_site,
"exists" if os.path.isdir(user_site) else "doesn't exist"))
print("ENABLE_USER_SITE: %r" % ENABLE_USER_SITE)
def exists(path):
if path is not None and os.path.isdir(path):
return "exists"
else:
return "doesn't exist"
print(f"USER_BASE: {user_base!r} ({exists(user_base)})")
print(f"USER_SITE: {user_site!r} ({exists(user_site)})")
print(f"ENABLE_USER_SITE: {ENABLE_USER_SITE!r}")
sys.exit(0)
buffer = []