From 94c262d3ed1734d392606310812e29ebb7eca35e Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Nov 09 2021 09:52:30 +0000 Subject: import python-virtualenv-15.1.0-21.module+el8.5.0+12203+77770ab7 --- diff --git a/SOURCES/rpm-wheels.patch b/SOURCES/rpm-wheels.patch index 6238af8..f17c00b 100644 --- a/SOURCES/rpm-wheels.patch +++ b/SOURCES/rpm-wheels.patch @@ -1,5 +1,14 @@ +From b7b8a713d9f1ebac6430fd0fc10175ed37b834ee Mon Sep 17 00:00:00 2001 +From: Lumir Balhar +Date: Thu, 18 Mar 2021 13:08:52 +0100 +Subject: [PATCH] rpm + +--- + virtualenv.py | 66 ++++++++++++++++++++++++++++++++++++++++++--------- + 1 file changed, 55 insertions(+), 11 deletions(-) + diff --git a/virtualenv.py b/virtualenv.py -index 5699998..55c7321 100755 +index 5699998..9854324 100755 --- a/virtualenv.py +++ b/virtualenv.py @@ -39,9 +39,9 @@ except ImportError: @@ -14,11 +23,103 @@ index 5699998..55c7321 100755 sys.exit(101) try: -@@ -399,6 +399,7 @@ def _find_file(filename, dirs): +@@ -399,6 +399,8 @@ def _find_file(filename, dirs): def file_search_dirs(): here = os.path.dirname(os.path.abspath(__file__)) dirs = [here, join(here, 'virtualenv_support')] + dirs.insert(1, '/usr/share/python{}-wheels'.format(sys.version_info[0])) ++ dirs.insert(1, '/usr/share/python{}{}-wheels'.format(*sys.version_info[:2])) if os.path.splitext(os.path.dirname(__file__))[0] != 'virtualenv': # Probably some boot script; just in case virtualenv is installed... try: +@@ -859,7 +861,12 @@ def install_wheel(project_names, py_executable, search_dirs=None, + import tempfile + import os + +- import pip ++ try: ++ from pip._internal import main as _main ++ if type(_main) is type(sys): # ++ _main = _main.main # nested starting in Pip 19.3 ++ except ImportError: ++ from pip import main as _main + + try: + cert_data = pkgutil.get_data("pip._vendor.requests", "cacert.pem") +@@ -878,7 +885,7 @@ def install_wheel(project_names, py_executable, search_dirs=None, + args += ["--cert", cert_file.name] + args += sys.argv[1:] + +- sys.exit(pip.main(args)) ++ sys.exit(_main(args)) + finally: + if cert_file is not None: + os.remove(cert_file.name) +@@ -1038,20 +1045,57 @@ def change_prefix(filename, dst_prefix): + assert False, "Filename %s does not start with any of these prefixes: %s" % \ + (filename, prefixes) + +-def copy_required_modules(dst_prefix, symlink): +- import imp ++def find_module_filename(modname): ++ if sys.version_info < (3, 4): ++ # noinspection PyDeprecation ++ import imp ++ ++ try: ++ file_handler, filepath, _ = imp.find_module(modname) ++ except ImportError: ++ return None ++ else: ++ if file_handler is not None: ++ file_handler.close() ++ return filepath ++ else: ++ import importlib.util + ++ if sys.version_info < (3, 5): ++ ++ def find_spec(modname): ++ # noinspection PyDeprecation ++ loader = importlib.find_loader(modname) ++ if loader is None: ++ return None ++ else: ++ return importlib.util.spec_from_loader(modname, loader) ++ ++ else: ++ find_spec = importlib.util.find_spec ++ ++ spec = find_spec(modname) ++ if spec is None: ++ return None ++ if not os.path.exists(spec.origin): ++ # https://bitbucket.org/pypy/pypy/issues/2944/origin-for-several-builtin-modules ++ # on pypy3, some builtin modules have a bogus build-time file path, ignore them ++ return None ++ filepath = spec.origin ++ # https://www.python.org/dev/peps/pep-3147/#file guarantee to be non-cached ++ if os.path.basename(filepath) == "__init__.py": ++ filepath = os.path.dirname(filepath) ++ return filepath ++ ++def copy_required_modules(dst_prefix, symlink): + for modname in REQUIRED_MODULES: + if modname in sys.builtin_module_names: + logger.info("Ignoring built-in bootstrap module: %s" % modname) + continue +- try: +- f, filename, _ = imp.find_module(modname) +- except ImportError: ++ filename = find_module_filename(modname) ++ if filename is None: + logger.info("Cannot import bootstrap module: %s" % modname) + else: +- if f is not None: +- f.close() + # special-case custom readline.so on OS X, but not for pypy: + if modname == 'readline' and sys.platform == 'darwin' and not ( + is_pypy or filename.endswith(join('lib-dynload', 'readline.so'))): +-- +2.30.2 + diff --git a/SPECS/python-virtualenv.spec b/SPECS/python-virtualenv.spec index 75f9256..eeaeb73 100644 --- a/SPECS/python-virtualenv.spec +++ b/SPECS/python-virtualenv.spec @@ -7,7 +7,7 @@ Name: python-virtualenv Version: 15.1.0 -Release: 19%{?dist} +Release: 21%{?dist} Summary: Tool to create isolated Python environments Group: Development/Languages @@ -20,13 +20,17 @@ Source0: http://pypi.python.org/packages/source/v/virtualenv/virtualenv-% # listing it's content. Patch0: check-exec_dir.patch -# Add /usr/share/python{2,3}-wheels to file_search_dirs -# and fail with a warning on versions of Python < 2.7 -Patch2: rpm-wheels.patch - # Don't fail on missing certifi's cert # https://github.com/pypa/virtualenv/pull/1252 -Patch3: dont-fail-on-missing-certifi-cert.patch +Patch1: dont-fail-on-missing-certifi-cert.patch + +# Changes related to RPM wheels: +# 1. Drop support for Python 2.6 because we don't have it in RHEL 8 and we don't want to +# bundle prehistoric wheels +# 2. Use wheels from /usr/share/python{2,3,38,39,...}-wheels +# 3. Add support for pip 19.3-ish by importing pip.main() from different locations +# 4. Use the importlib module rather than deprecated imp on Python 3 +Patch2: rpm-wheels.patch BuildArch: noarch @@ -75,6 +79,9 @@ Requires: python2-devel Requires: python2-pip-wheel Requires: python2-setuptools-wheel Requires: python2-wheel-wheel +Requires: (python3-wheel-wheel if python36) +Requires: (python38-wheel-wheel if python38) +Requires: (python39-wheel-wheel if python39) %{?python_provide:%python_provide python2-virtualenv} @@ -102,11 +109,17 @@ Requires: python3-setuptools Requires: python3-pip-wheel Requires: python3-setuptools-wheel Requires: python3-wheel-wheel +Requires: (python2-wheel-wheel if python2) +Requires: (python38-wheel-wheel if python38) +Requires: (python39-wheel-wheel if python39) +# Require alternatives version that implements the --keep-foreign flag +Requires(postun): alternatives >= 1.19.1-1 # For alternatives Requires: python36 Requires(post): python36 Requires(postun): python36 + %if %{with python36_module} Requires: python36-devel %else @@ -128,8 +141,8 @@ licensed under an MIT-style permissive license %{__sed} -i -e "1s|#!/usr/bin/env python||" virtualenv.py %patch0 -p1 +%patch1 -p1 %patch2 -p1 -%patch3 -p1 # Remove the wheels provided by RPM packages and argparse as it's only required for python 2.6 rm virtualenv_support/pip-* @@ -187,9 +200,9 @@ alternatives --add-slave python3 %{_bindir}/python%{python3_version} \ %postun -n python3-virtualenv # Do this only during uninstall process (not during update) if [ $1 -eq 0 ]; then - alternatives --remove-slave python3 %{_bindir}/python%{python3_version} \ + alternatives --keep-foreign --remove-slave python3 %{_bindir}/python%{python3_version} \ virtualenv-3 - alternatives --remove-slave python3 %{_bindir}/python%{python3_version} \ + alternatives --keep-foreign --remove-slave python3 %{_bindir}/python%{python3_version} \ virtualenv fi %endif @@ -226,6 +239,14 @@ fi %changelog +* Wed Jul 28 2021 Tomas Orsava - 15.1.0-21 +- Adjusted the postun scriptlets to enable upgrading to RHEL 9 +- Resolves: rhbz#1933055 + +* Thu Mar 18 2021 Lumír Balhar - 15.1.0-20 +- Use python-version-specific wheels from Python modules +Resolves: rhbz#1917971 + * Fri Jun 21 2019 Miro Hrončok - 15.1.0-19 - Use wheels from RPM packages (rhbz#1659550) (rhbz#1659551) - Fail with a warning on Python versions < 2.7