diff --git a/adapted-from-F00251-change-user-install-location.patch b/adapted-from-F00251-change-user-install-location.patch new file mode 100644 index 0000000..84e7edc --- /dev/null +++ b/adapted-from-F00251-change-user-install-location.patch @@ -0,0 +1,40 @@ +Index: Python-2.7.17/Lib/distutils/command/install.py +=================================================================== +--- Python-2.7.17.orig/Lib/distutils/command/install.py ++++ Python-2.7.17/Lib/distutils/command/install.py +@@ -431,8 +431,18 @@ class install (Command): + raise DistutilsOptionError, \ + "must not supply exec-prefix without prefix" + +- self.prefix = os.path.normpath(sys.prefix) +- self.exec_prefix = os.path.normpath(sys.exec_prefix) ++ # self.prefix is set to sys.prefix + /local/ ++ # if neither RPM build nor virtual environment is ++ # detected to make pip and distutils install packages ++ # into the separate location. ++ if (not hasattr(sys, 'real_prefix') and ++ 'RPM_BUILD_ROOT' not in os.environ): ++ addition = "/local" ++ else: ++ addition = "" ++ ++ self.prefix = os.path.normpath(sys.prefix) + addition ++ self.exec_prefix = os.path.normpath(sys.exec_prefix) + addition + + else: + if self.exec_prefix is None: +Index: Python-2.7.17/Lib/site.py +=================================================================== +--- Python-2.7.17.orig/Lib/site.py ++++ Python-2.7.17/Lib/site.py +@@ -291,6 +291,10 @@ def getsitepackages(): + sitepackages = [] + seen = set() + ++ # '/usr/local' is included in PREFIXES if RPM build is not detected ++ # to make packages installed into this location visible. ++ if ENABLE_USER_SITE and 'RPM_BUILD_ROOT' not in os.environ: ++ PREFIXES.insert(0, "/usr/local") + for prefix in PREFIXES: + if not prefix or prefix in seen: + continue diff --git a/python-base.changes b/python-base.changes index 6bda782..07310a2 100644 --- a/python-base.changes +++ b/python-base.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Tue Nov 5 04:24:05 UTC 2019 - Steve Kowalik + +- Add adapted-from-F00251-change-user-install-location.patch fixing + pip/distutils to install into /usr/local. + ------------------------------------------------------------------- Thu Oct 24 14:40:39 CEST 2019 - Matej Cepl diff --git a/python-base.spec b/python-base.spec index 2fd6d8a..36bfdca 100644 --- a/python-base.spec +++ b/python-base.spec @@ -74,6 +74,12 @@ Patch49: CVE-2019-5010-null-defer-x509-cert-DOS.patch Patch50: bpo36160-init-sysconfig_vars.patch # PATCH-FIX-UPSTREAM https://github.com/python/cpython/pull/12341 Patch55: bpo36302-sort-module-sources.patch +# Fix installation in /usr/local (boo#1071941), adapted from Fedora +# https://src.fedoraproject.org/rpms/python3/blob/master/f/00251-change-user-install-location.patch +# Set values of prefix and exec_prefix in distutils install command +# to /usr/local if executable is /usr/bin/python* and RPM build +# is not detected to make pip and distutils install into separate location +Patch56: adapted-from-F00251-change-user-install-location.patch # COMMON-PATCH-END %define python_version %(echo %{tarversion} | head -c 3) BuildRequires: automake @@ -186,6 +192,7 @@ other applications. %patch49 -p1 %patch50 -p1 %patch55 -p1 +%patch56 -p1 # drop Autoconf version requirement sed -i 's/^version_required/dnl version_required/' configure.ac