summaryrefslogtreecommitdiffstats
path: root/Lib/site.py
diff options
context:
space:
mode:
authorpxinwr <peixing.xin@windriver.com>2020-12-20 22:27:42 (GMT)
committerGitHub <noreply@github.com>2020-12-20 22:27:42 (GMT)
commitab74c014ae514fde7487542ec96ef45235aa86b0 (patch)
tree95f63ef81a87a9d975421287d6d0dbe1b24f4e2e /Lib/site.py
parentc95f8bc2700b42f4568886505a819816c9b0ba28 (diff)
downloadcpython-ab74c014ae514fde7487542ec96ef45235aa86b0.zip
cpython-ab74c014ae514fde7487542ec96ef45235aa86b0.tar.gz
cpython-ab74c014ae514fde7487542ec96ef45235aa86b0.tar.bz2
bpo-31904: Fix site and sysconfig modules for VxWorks RTOS (GH-21821)
Diffstat (limited to 'Lib/site.py')
-rw-r--r--Lib/site.py24
1 files changed, 17 insertions, 7 deletions
diff --git a/Lib/site.py b/Lib/site.py
index 3a0f619..5f1b31e 100644
--- a/Lib/site.py
+++ b/Lib/site.py
@@ -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 = []