File tree 3 files changed +30
-2
lines changed
3 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -380,8 +380,15 @@ def getsitepackages(prefixes=None):
380
380
return sitepackages
381
381
382
382
def addsitepackages (known_paths , prefixes = None ):
383
- """Add site-packages to sys.path"""
383
+ """Add site-packages to sys.path
384
+
385
+ '/usr/local' is included in PREFIXES if RPM build is not detected
386
+ to make packages installed into this location visible.
387
+
388
+ """
384
389
_trace ("Processing global site-packages" )
390
+ if ENABLE_USER_SITE and 'RPM_BUILD_ROOT' not in os .environ :
391
+ PREFIXES .insert (0 , "/usr/local" )
385
392
for sitedir in getsitepackages (prefixes ):
386
393
if os .path .isdir (sitedir ):
387
394
addsitedir (sitedir , known_paths )
Original file line number Diff line number Diff line change 58
58
},
59
59
}
60
60
61
+ # backup the original posix_prefix as rpm_prefix
62
+ # RPM packages use it and we need to be able to read it even when changed
63
+ _INSTALL_SCHEMES ['rpm_prefix' ] = _INSTALL_SCHEMES ['posix_prefix' ]
64
+
65
+ if (not (hasattr (sys , 'real_prefix' ) or
66
+ sys .prefix != sys .base_prefix ) and
67
+ 'RPM_BUILD_ROOT' not in os .environ ):
68
+ _INSTALL_SCHEMES ['posix_prefix' ] = {
69
+ 'stdlib' : '{installed_base}/{platlibdir}/python{py_version_short}' ,
70
+ 'platstdlib' : '{platbase}/{platlibdir}/python{py_version_short}' ,
71
+ 'purelib' : '{base}/local/lib/python{py_version_short}/site-packages' ,
72
+ 'platlib' : '{platbase}/local/{platlibdir}/python{py_version_short}/site-packages' ,
73
+ 'include' :
74
+ '{installed_base}/include/python{py_version_short}{abiflags}' ,
75
+ 'platinclude' :
76
+ '{installed_platbase}/include/python{py_version_short}{abiflags}' ,
77
+ 'scripts' : '{base}/local/bin' ,
78
+ 'data' : '{base}/local' ,
79
+ }
61
80
62
81
# NOTE: site.py has copy of this function.
63
82
# Sync it when modify this function.
Original file line number Diff line number Diff line change @@ -263,7 +263,7 @@ def test_get_config_h_filename(self):
263
263
self .assertTrue (os .path .isfile (config_h ), config_h )
264
264
265
265
def test_get_scheme_names (self ):
266
- wanted = ['nt' , 'posix_home' , 'posix_prefix' ]
266
+ wanted = ['nt' , 'posix_home' , 'posix_prefix' , 'rpm_prefix' ]
267
267
if HAS_USER_BASE :
268
268
wanted .extend (['nt_user' , 'osx_framework_user' , 'posix_user' ])
269
269
self .assertEqual (get_scheme_names (), tuple (sorted (wanted )))
@@ -274,6 +274,8 @@ def test_symlink(self): # Issue 7880
274
274
cmd = "-c" , "import sysconfig; print(sysconfig.get_platform())"
275
275
self .assertEqual (py .call_real (* cmd ), py .call_link (* cmd ))
276
276
277
+ @unittest .skipIf ('RPM_BUILD_ROOT' not in os .environ ,
278
+ "Test doesn't expect Fedora's paths" )
277
279
def test_user_similar (self ):
278
280
# Issue #8759: make sure the posix scheme for the users
279
281
# is similar to the global posix_prefix one
You can’t perform that action at this time.
0 commit comments