|
51 | 51 | 'scripts': '{base}/Scripts', |
52 | 52 | 'data': '{base}', |
53 | 53 | }, |
54 | | - # NOTE: When modifying "purelib" scheme, update site._get_path() too. |
55 | | - 'nt_user': { |
56 | | - 'stdlib': '{userbase}/Python{py_version_nodot_plat}', |
57 | | - 'platstdlib': '{userbase}/Python{py_version_nodot_plat}', |
58 | | - 'purelib': '{userbase}/Python{py_version_nodot_plat}/site-packages', |
59 | | - 'platlib': '{userbase}/Python{py_version_nodot_plat}/site-packages', |
60 | | - 'include': '{userbase}/Python{py_version_nodot_plat}/Include', |
61 | | - 'scripts': '{userbase}/Python{py_version_nodot_plat}/Scripts', |
62 | | - 'data': '{userbase}', |
63 | | - }, |
64 | | - 'posix_user': { |
65 | | - 'stdlib': '{userbase}/{platlibdir}/python{py_version_short}', |
66 | | - 'platstdlib': '{userbase}/{platlibdir}/python{py_version_short}', |
67 | | - 'purelib': '{userbase}/lib/python{py_version_short}/site-packages', |
68 | | - 'platlib': '{userbase}/{platlibdir}/python{py_version_short}/site-packages', |
69 | | - 'include': '{userbase}/include/python{py_version_short}', |
70 | | - 'scripts': '{userbase}/bin', |
71 | | - 'data': '{userbase}', |
72 | | - }, |
73 | | - 'osx_framework_user': { |
74 | | - 'stdlib': '{userbase}/lib/python', |
75 | | - 'platstdlib': '{userbase}/lib/python', |
76 | | - 'purelib': '{userbase}/lib/python/site-packages', |
77 | | - 'platlib': '{userbase}/lib/python/site-packages', |
78 | | - 'include': '{userbase}/include', |
79 | | - 'scripts': '{userbase}/bin', |
80 | | - 'data': '{userbase}', |
81 | | - }, |
| 54 | + } |
| 55 | + |
| 56 | + |
| 57 | +# NOTE: site.py has copy of this function. |
| 58 | +# Sync it when modify this function. |
| 59 | +def _getuserbase(): |
| 60 | + env_base = os.environ.get("PYTHONUSERBASE", None) |
| 61 | + if env_base: |
| 62 | + return env_base |
| 63 | + |
| 64 | + # VxWorks has no home directories |
| 65 | + if sys.platform == "vxworks": |
| 66 | + return None |
| 67 | + |
| 68 | + def joinuser(*args): |
| 69 | + return os.path.expanduser(os.path.join(*args)) |
| 70 | + |
| 71 | + if os.name == "nt": |
| 72 | + base = os.environ.get("APPDATA") or "~" |
| 73 | + return joinuser(base, "Python") |
| 74 | + |
| 75 | + if sys.platform == "darwin" and sys._framework: |
| 76 | + return joinuser("~", "Library", sys._framework, |
| 77 | + "%d.%d" % sys.version_info[:2]) |
| 78 | + |
| 79 | + return joinuser("~", ".local") |
| 80 | + |
| 81 | +_HAS_USER_BASE = (_getuserbase() is not None) |
| 82 | + |
| 83 | +if _HAS_USER_BASE: |
| 84 | + _INSTALL_SCHEMES |= { |
| 85 | + # NOTE: When modifying "purelib" scheme, update site._get_path() too. |
| 86 | + 'nt_user': { |
| 87 | + 'stdlib': '{userbase}/Python{py_version_nodot_plat}', |
| 88 | + 'platstdlib': '{userbase}/Python{py_version_nodot_plat}', |
| 89 | + 'purelib': '{userbase}/Python{py_version_nodot_plat}/site-packages', |
| 90 | + 'platlib': '{userbase}/Python{py_version_nodot_plat}/site-packages', |
| 91 | + 'include': '{userbase}/Python{py_version_nodot_plat}/Include', |
| 92 | + 'scripts': '{userbase}/Python{py_version_nodot_plat}/Scripts', |
| 93 | + 'data': '{userbase}', |
| 94 | + }, |
| 95 | + 'posix_user': { |
| 96 | + 'stdlib': '{userbase}/{platlibdir}/python{py_version_short}', |
| 97 | + 'platstdlib': '{userbase}/{platlibdir}/python{py_version_short}', |
| 98 | + 'purelib': '{userbase}/lib/python{py_version_short}/site-packages', |
| 99 | + 'platlib': '{userbase}/{platlibdir}/python{py_version_short}/site-packages', |
| 100 | + 'include': '{userbase}/include/python{py_version_short}', |
| 101 | + 'scripts': '{userbase}/bin', |
| 102 | + 'data': '{userbase}', |
| 103 | + }, |
| 104 | + 'osx_framework_user': { |
| 105 | + 'stdlib': '{userbase}/lib/python', |
| 106 | + 'platstdlib': '{userbase}/lib/python', |
| 107 | + 'purelib': '{userbase}/lib/python/site-packages', |
| 108 | + 'platlib': '{userbase}/lib/python/site-packages', |
| 109 | + 'include': '{userbase}/include', |
| 110 | + 'scripts': '{userbase}/bin', |
| 111 | + 'data': '{userbase}', |
| 112 | + }, |
82 | 113 | } |
83 | 114 |
|
84 | 115 | _SCHEME_KEYS = ('stdlib', 'platstdlib', 'purelib', 'platlib', 'include', |
@@ -183,25 +214,6 @@ def _get_default_scheme(): |
183 | 214 | return os.name |
184 | 215 |
|
185 | 216 |
|
186 | | -# NOTE: site.py has copy of this function. |
187 | | -# Sync it when modify this function. |
188 | | -def _getuserbase(): |
189 | | - env_base = os.environ.get("PYTHONUSERBASE", None) |
190 | | - if env_base: |
191 | | - return env_base |
192 | | - |
193 | | - def joinuser(*args): |
194 | | - return os.path.expanduser(os.path.join(*args)) |
195 | | - |
196 | | - if os.name == "nt": |
197 | | - base = os.environ.get("APPDATA") or "~" |
198 | | - return joinuser(base, "Python") |
199 | | - |
200 | | - if sys.platform == "darwin" and sys._framework: |
201 | | - return joinuser("~", "Library", sys._framework, |
202 | | - "%d.%d" % sys.version_info[:2]) |
203 | | - |
204 | | - return joinuser("~", ".local") |
205 | 217 |
|
206 | 218 |
|
207 | 219 | def _parse_makefile(filename, vars=None): |
@@ -558,10 +570,11 @@ def get_config_vars(*args): |
558 | 570 | SO = _CONFIG_VARS.get('EXT_SUFFIX') |
559 | 571 | if SO is not None: |
560 | 572 | _CONFIG_VARS['SO'] = SO |
561 | | - # Setting 'userbase' is done below the call to the |
562 | | - # init function to enable using 'get_config_var' in |
563 | | - # the init-function. |
564 | | - _CONFIG_VARS['userbase'] = _getuserbase() |
| 573 | + if _HAS_USER_BASE: |
| 574 | + # Setting 'userbase' is done below the call to the |
| 575 | + # init function to enable using 'get_config_var' in |
| 576 | + # the init-function. |
| 577 | + _CONFIG_VARS['userbase'] = _getuserbase() |
565 | 578 |
|
566 | 579 | # Always convert srcdir to an absolute path |
567 | 580 | srcdir = _CONFIG_VARS.get('srcdir', _PROJECT_BASE) |
|
0 commit comments