()
| 107 | # NOTE: site.py has copy of this function. |
| 108 | # Sync it when modify this function. |
| 109 | def _getuserbase(): |
| 110 | env_base = os.environ.get("PYTHONUSERBASE", None) |
| 111 | if env_base: |
| 112 | return env_base |
| 113 | |
| 114 | # Emscripten, VxWorks, and WASI have no home directories |
| 115 | if sys.platform in {"emscripten", "vxworks", "wasi"}: |
| 116 | return None |
| 117 | |
| 118 | def joinuser(*args): |
| 119 | return os.path.expanduser(os.path.join(*args)) |
| 120 | |
| 121 | if os.name == "nt": |
| 122 | base = os.environ.get("APPDATA") or "~" |
| 123 | return joinuser(base, "Python") |
| 124 | |
| 125 | if sys.platform == "darwin" and sys._framework: |
| 126 | return joinuser("~", "Library", sys._framework, |
| 127 | f"{sys.version_info[0]}.{sys.version_info[1]}") |
| 128 | |
| 129 | return joinuser("~", ".local") |
| 130 | |
| 131 | _HAS_USER_BASE = (_getuserbase() is not None) |
| 132 |
no test coverage detected