From fb4382e9a45fc745f499fc4ab45211df2eaf7cd5 Mon Sep 17 00:00:00 2001 From: Gautham <41098605+ahgamut@users.noreply.github.com> Date: Fri, 20 May 2022 20:47:10 +0530 Subject: [PATCH] os.realname variable for correct USER_SITE value (#410) In site.py, Python uses os.name to decide where the USER_SITE (ie the folder containing the user's locally installed packages) is located. With cosmo we have set os.name as "posix" always, so we use a new os.realname to decide the USER_SITE location. --- third_party/python/Lib/os.py | 1 + third_party/python/Lib/site.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/third_party/python/Lib/os.py b/third_party/python/Lib/os.py index 76f62113b..df52811da 100644 --- a/third_party/python/Lib/os.py +++ b/third_party/python/Lib/os.py @@ -42,6 +42,7 @@ def _get_exports_list(module): name = 'posix' linesep = '\n' +realname = "nt" if cosmo.kernel == "nt" else "posix" from posix import * from posix import _exit __all__.append('_exit') diff --git a/third_party/python/Lib/site.py b/third_party/python/Lib/site.py index 40b0c865a..a58ae18da 100644 --- a/third_party/python/Lib/site.py +++ b/third_party/python/Lib/site.py @@ -240,7 +240,7 @@ def _getuserbase(): def joinuser(*args): return os.path.expanduser(os.path.join(*args)) - if os.name == "nt": + if os.realname == "nt": base = os.environ.get("APPDATA") or "~" if env_base: return env_base @@ -298,7 +298,7 @@ def getusersitepackages(): "posix_user":'{userbase}/lib/python3.6/site-packages', "nt_user": "{userbase}/Python36/site-packages", } - USER_SITE = purelib_map.get('%s_user' % os.name).format(userbase=user_base) + USER_SITE = purelib_map.get('%s_user' % os.realname).format(userbase=user_base) return USER_SITE def addusersitepackages(known_paths):