MCPcopy Index your code
hub / github.com/python/cpython / _getuserbase

Function _getuserbase

Lib/sysconfig/__init__.py:114–136  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

112# NOTE: site.py has copy of this function.
113# Sync it when modify this function.
114def _getuserbase():
115 env_base = os.environ.get("PYTHONUSERBASE", None)
116 if env_base:
117 return env_base
118
119 # Emscripten, iOS, tvOS, VxWorks, WASI, and watchOS have no home directories.
120 # Use _PYTHON_HOST_PLATFORM to get the correct platform when cross-compiling.
121 system_name = os.environ.get('_PYTHON_HOST_PLATFORM', sys.platform).split('-')[0]
122 if system_name in {"emscripten", "ios", "tvos", "vxworks", "wasi", "watchos"}:
123 return None
124
125 def joinuser(*args):
126 return os.path.expanduser(os.path.join(*args))
127
128 if os.name == "nt":
129 base = os.environ.get("APPDATA") or "~"
130 return joinuser(base, _get_implementation())
131
132 if sys.platform == "darwin" and sys._framework:
133 return joinuser("~", "Library", sys._framework,
134 f"{sys.version_info[0]}.{sys.version_info[1]}")
135
136 return joinuser("~", ".local")
137
138_HAS_USER_BASE = (_getuserbase() is not None)
139

Callers 2

__init__.pyFile · 0.70
_init_config_varsFunction · 0.70

Calls 4

joinuserFunction · 0.70
_get_implementationFunction · 0.70
getMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…