]>
Commit | Line | Data |
---|---|---|
a2b17ec1 AM |
1 | diff --git a/Lib/site.py b/Lib/site.py |
2 | --- a/Lib/site.py | |
3 | +++ b/Lib/site.py | |
4 | @@ -262,7 +266,7 @@ def addusersitepackages(known_paths): | |
5 | # this call will also make sure USER_BASE and USER_SITE are set | |
6 | user_site = getusersitepackages() | |
7 | ||
8 | - if ENABLE_USER_SITE and os.path.isdir(user_site): | |
9 | + if ENABLE_USER_SITE and user_site and os.path.isdir(user_site): | |
10 | addsitedir(user_site, known_paths) | |
11 | return known_paths | |
12 | ||
13 | diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py | |
14 | --- a/Lib/sysconfig.py | |
15 | +++ b/Lib/sysconfig.py | |
16 | @@ -170,7 +170,13 @@ def _expand_vars(scheme, vars): | |
17 | for key, value in _INSTALL_SCHEMES[scheme].items(): | |
18 | if os.name in ('posix', 'nt'): | |
19 | value = os.path.expanduser(value) | |
20 | - res[key] = os.path.normpath(_subst_vars(value, vars)) | |
21 | + try: | |
22 | + path = _subst_vars(value, vars) | |
23 | + except AttributeError: | |
24 | + # a substitution variable doesn't exist (eg. '{userbase}'), | |
25 | + # don't create the variable | |
26 | + continue | |
27 | + res[key] = os.path.normpath(path) | |
28 | return res | |
29 | ||
30 | def _get_default_scheme(): | |
31 | @@ -488,7 +494,12 @@ def get_config_vars(*args): | |
32 | # Setting 'userbase' is done below the call to the | |
33 | # init function to enable using 'get_config_var' in | |
34 | # the init-function. | |
35 | - _CONFIG_VARS['userbase'] = _getuserbase() | |
36 | + try: | |
37 | + _CONFIG_VARS['userbase'] = _getuserbase() | |
38 | + except KeyError: | |
39 | + # catch getpwuid() error: don't create the variable if the user | |
40 | + # doesn't exist | |
41 | + pass | |
42 | ||
43 | if 'srcdir' not in _CONFIG_VARS: | |
44 | _CONFIG_VARS['srcdir'] = _PROJECT_BASE |