diff -up Python-3.11.0a7/Lib/site.py.2~ Python-3.11.0a7/Lib/site.py --- Python-3.11.0a7/Lib/site.py.2~ 2022-04-05 21:54:03.000000000 +0200 +++ Python-3.11.0a7/Lib/site.py 2022-04-07 19:08:48.674408380 +0200 @@ -377,8 +377,15 @@ def getsitepackages(prefixes=None): return sitepackages def addsitepackages(known_paths, prefixes=None): - """Add site-packages to sys.path""" + """Add site-packages to sys.path + + '/usr/local' is included in PREFIXES if RPM build is not detected + to make packages installed into this location visible. + + """ _trace("Processing global site-packages") + if ENABLE_USER_SITE and 'RPM_BUILD_ROOT' not in os.environ: + PREFIXES.insert(0, "/usr/local") for sitedir in getsitepackages(prefixes): if os.path.isdir(sitedir): addsitedir(sitedir, known_paths) diff -up Python-3.11.0a7/Lib/sysconfig.py.2~ Python-3.11.0a7/Lib/sysconfig.py --- Python-3.11.0a7/Lib/sysconfig.py.2~ 2022-04-07 19:08:48.674408380 +0200 +++ Python-3.11.0a7/Lib/sysconfig.py 2022-04-07 19:10:00.549687607 +0200 @@ -103,6 +103,31 @@ if os.name == 'nt': else: _INSTALL_SCHEMES['venv'] = _INSTALL_SCHEMES['posix_venv'] +# backup the original posix_prefix as rpm_prefix +# RPM packages use it and we need to be able to read it even when changed +_INSTALL_SCHEMES['rpm_prefix'] = _INSTALL_SCHEMES['posix_prefix'] +# Virtualenv >= 20.10.0 favors the "venv" scheme over the defaults when creating virtual environments. +# See: https://github.com/pypa/virtualenv/commit/8da79db86d8a5c74d03667a40e64ff832076445e +# See: https://bugs.python.org/issue45413 +# "venv" should be the same as the unpatched posix_prefix for us, +# so new virtual environments aren't created with paths like venv/local/bin/python. +_INSTALL_SCHEMES['venv'] = _INSTALL_SCHEMES['posix_prefix'] + +if (not (hasattr(sys, 'real_prefix') or + sys.prefix != sys.base_prefix) and + 'RPM_BUILD_ROOT' not in os.environ): + _INSTALL_SCHEMES['posix_prefix'] = { + 'stdlib': '{installed_base}/{platlibdir}/python{py_version_short}', + 'platstdlib': '{platbase}/{platlibdir}/python{py_version_short}', + 'purelib': '{base}/local/lib/python{py_version_short}/site-packages', + 'platlib': '{platbase}/local/{platlibdir}/python{py_version_short}/site-packages', + 'include': + '{installed_base}/include/python{py_version_short}{abiflags}', + 'platinclude': + '{installed_platbase}/include/python{py_version_short}{abiflags}', + 'scripts': '{base}/local/bin', + 'data': '{base}/local', + } # NOTE: site.py has copy of this function. # Sync it when modify this function. diff -up Python-3.11.0a7/Lib/test/test_sysconfig.py.2~ Python-3.11.0a7/Lib/test/test_sysconfig.py --- Python-3.11.0a7/Lib/test/test_sysconfig.py.2~ 2022-04-05 21:54:03.000000000 +0200 +++ Python-3.11.0a7/Lib/test/test_sysconfig.py 2022-04-07 19:10:32.618812176 +0200 @@ -333,7 +333,7 @@ class TestSysConfig(unittest.TestCase): self.assertTrue(os.path.isfile(config_h), config_h) def test_get_scheme_names(self): - wanted = ['nt', 'posix_home', 'posix_prefix', 'posix_venv', 'nt_venv', 'venv'] + wanted = ['nt', 'posix_home', 'posix_prefix', 'posix_venv', 'nt_venv', 'venv', 'rpm_prefix'] if HAS_USER_BASE: wanted.extend(['nt_user', 'osx_framework_user', 'posix_user']) self.assertEqual(get_scheme_names(), tuple(sorted(wanted))) @@ -345,6 +345,8 @@ class TestSysConfig(unittest.TestCase): cmd = "-c", "import sysconfig; print(sysconfig.get_platform())" self.assertEqual(py.call_real(*cmd), py.call_link(*cmd)) + @unittest.skipIf('RPM_BUILD_ROOT' not in os.environ, + "Test doesn't expect Fedora's paths") def test_user_similar(self): # Issue #8759: make sure the posix scheme for the users # is similar to the global posix_prefix one