From 9d4d4ef0bd6ad3238ef60aa856849546864cc92a Mon Sep 17 00:00:00 2001 From: Lumir Balhar Date: Tue, 9 Nov 2021 14:48:28 +0100 Subject: [PATCH] Remove hack for local/ prefixes Python 3.10 and 3.11 in rawhide will have a new "venv" scheme which virtualenv in the latest version prefers. --- 2231.patch | 54 +++++++++++++++++++++++++++++++++++++++++ hack_around_local.patch | 14 ----------- python-virtualenv.spec | 18 +++++++++++--- 3 files changed, 68 insertions(+), 18 deletions(-) create mode 100644 2231.patch delete mode 100644 hack_around_local.patch diff --git a/2231.patch b/2231.patch new file mode 100644 index 0000000..1061fa1 --- /dev/null +++ b/2231.patch @@ -0,0 +1,54 @@ +From 58ff51c482ed40a6b38766c90954d7d3edcaa0fb Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= +Date: Mon, 8 Nov 2021 15:54:18 +0100 +Subject: [PATCH] Fix test_custom_venv_install_scheme_is_prefered mocking if + "venv" install scheme actually exists + +The error this prevents was: + + """distutils.command.install + + Implements the Distutils 'install' command.""" + + ... + + # Copy from sysconfig._INSTALL_SCHEMES + for key in SCHEME_KEYS: + for distutils_scheme_name, sys_scheme_name in ( + ("unix_prefix", "posix_prefix"), ("unix_home", "posix_home"), + ("nt", "nt")): + sys_key = key + > sys_scheme = sysconfig._INSTALL_SCHEMES[sys_scheme_name] + E KeyError: 'posix_home' +--- + tests/unit/discovery/py_info/test_py_info.py | 9 ++++++++- + 1 file changed, 8 insertions(+), 1 deletion(-) + +diff --git a/tests/unit/discovery/py_info/test_py_info.py b/tests/unit/discovery/py_info/test_py_info.py +index 053a6f906..d4c4bba25 100644 +--- a/tests/unit/discovery/py_info/test_py_info.py ++++ b/tests/unit/discovery/py_info/test_py_info.py +@@ -349,7 +349,6 @@ def test_custom_venv_install_scheme_is_prefered(mocker): + + if sys.version_info[0] == 2: + sysconfig_install_schemes = _stringify_schemes_dict(sysconfig_install_schemes) +- mocker.patch("sysconfig._INSTALL_SCHEMES", sysconfig_install_schemes) + + # On Python < 3.10, the distutils schemes are not derived from sysconfig schemes + # So we mock them as well to assert the custom "venv" install scheme has priority +@@ -367,7 +366,15 @@ def test_custom_venv_install_scheme_is_prefered(mocker): + + if sys.version_info[0] == 2: + distutils_schemes = _stringify_schemes_dict(distutils_schemes) ++ ++ # We need to mock distutils first, so they don't see the mocked sysconfig, ++ # if imported for the first time. ++ # That can happen if the actual interpreter has the "venv" INSTALL_SCHEME ++ # and hence this is the first time we are touching distutils in this process. ++ # If distutils saw our mocked sysconfig INSTALL_SCHEMES, we would need ++ # to define all install schemes. + mocker.patch("distutils.command.install.INSTALL_SCHEMES", distutils_schemes) ++ mocker.patch("sysconfig._INSTALL_SCHEMES", sysconfig_install_schemes) + + pyinfo = PythonInfo() + pyver = "{}.{}".format(pyinfo.version_info.major, pyinfo.version_info.minor) diff --git a/hack_around_local.patch b/hack_around_local.patch deleted file mode 100644 index a34a5c8..0000000 --- a/hack_around_local.patch +++ /dev/null @@ -1,14 +0,0 @@ -diff --git a/src/virtualenv/discovery/py_info.py b/src/virtualenv/discovery/py_info.py -index 0de6128..006df83 100644 ---- a/src/virtualenv/discovery/py_info.py -+++ b/src/virtualenv/discovery/py_info.py -@@ -124,6 +124,9 @@ class PythonInfo(object): - prefixes = self.prefix, self.exec_prefix, self.base_prefix, self.base_exec_prefix - config_var = {k: "" if v in prefixes else v for k, v in self.sysconfig_vars.items()} - result = self.sysconfig_path(key, config_var=config_var).lstrip(os.sep) -+ # A hack for https://github.com/pypa/virtualenv/issues/2208 -+ if result.startswith(u"local/"): -+ return result[6:] - return result - - @staticmethod diff --git a/python-virtualenv.spec b/python-virtualenv.spec index 2d34546..c47f165 100644 --- a/python-virtualenv.spec +++ b/python-virtualenv.spec @@ -1,6 +1,6 @@ Name: python-virtualenv Version: 20.10.0 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Tool to create isolated Python environments License: MIT @@ -10,9 +10,8 @@ Source0: %{pypi_source virtualenv} # Add /usr/share/python-wheels to extra_search_dir Patch1: rpm-wheels.patch -# A hack/workaround for https://github.com/pypa/virtualenv/issues/2208 -# This makes virtualenv's paths not contain /local/ -Patch2: hack_around_local.patch +# Hotfix for the test of the new functionality +Patch2: https://github.com/pypa/virtualenv/pull/2231.patch BuildArch: noarch @@ -60,6 +59,14 @@ licensed under an MIT-style permissive license. %package -n python3-virtualenv Summary: Tool to create isolated Python environments +# This virtualenv requires the "venv" install scheme on Pythons +# where we patch "posix_prefix". +# Explicitly conflict with Pythons where we don't have it yet. +Conflicts: python3.11 < 3.11.0~a2 +%if 0%{?fedora} >= 36 +Conflicts: python3.10 < 3.10.0-3 +%endif + Obsoletes: python3-virtualenv-python26 < 16.6 %{?python_provide:%python_provide python3-virtualenv} @@ -155,6 +162,9 @@ rm -r tmp_path %changelog +* Mon Nov 08 2021 Lumír Balhar - 20.10.0-2 +- Remove hack for local/ prefixes + * Tue Nov 02 2021 Lumír Balhar - 20.10.0-1 - Update to 20.10.0 Resolves: rhbz#2019116