From fb67bee376836e6d7e6ccabc3f81532a913d15d7 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: May 16 2023 06:21:01 +0000 Subject: import python-virtualenv-15.1.0-22.module+el8.8.0+18131+2eb9cbd8 --- diff --git a/SOURCES/python3.10.patch b/SOURCES/python3.10.patch new file mode 100644 index 0000000..b0c54b0 --- /dev/null +++ b/SOURCES/python3.10.patch @@ -0,0 +1,230 @@ +diff --git a/virtualenv.py b/virtualenv.py +index 9854324..e5d0883 100755 +--- a/virtualenv.py ++++ b/virtualenv.py +@@ -49,7 +49,8 @@ try: + except NameError: + basestring = str + +-py_version = 'python%s.%s' % (sys.version_info[0], sys.version_info[1]) ++version = '%s.%s' % (sys.version_info[0], sys.version_info[1]) ++py_version = 'python%s' % version + + is_jython = sys.platform.startswith('java') + is_pypy = hasattr(sys, 'pypy_version_info') +@@ -1012,13 +1013,13 @@ def change_prefix(filename, dst_prefix): + + if is_darwin: + prefixes.extend(( +- os.path.join("/Library/Python", sys.version[:3], "site-packages"), ++ os.path.join("/Library/Python", version, "site-packages"), + os.path.join(sys.prefix, "Extras", "lib", "python"), +- os.path.join("~", "Library", "Python", sys.version[:3], "site-packages"), ++ os.path.join("~", "Library", "Python", version, "site-packages"), + # Python 2.6 no-frameworks +- os.path.join("~", ".local", "lib","python", sys.version[:3], "site-packages"), ++ os.path.join("~", ".local", "lib","python", version, "site-packages"), + # System Python 2.7 on OSX Mountain Lion +- os.path.join("~", "Library", "Python", sys.version[:3], "lib", "python", "site-packages"))) ++ os.path.join("~", "Library", "Python", version, "lib", "python", "site-packages"))) + + if hasattr(sys, 'real_prefix'): + prefixes.append(sys.real_prefix) +@@ -1099,7 +1100,7 @@ def copy_required_modules(dst_prefix, symlink): + # 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'))): +- dst_filename = join(dst_prefix, 'lib', 'python%s' % sys.version[:3], 'readline.so') ++ dst_filename = join(dst_prefix, 'lib', py_version, 'readline.so') + elif modname == 'readline' and sys.platform == 'win32': + # special-case for Windows, where readline is not a + # standard module, though it may have been installed in +@@ -1398,8 +1399,7 @@ def install_python(home_dir, lib_dir, inc_dir, bin_dir, site_packages, clear, sy + if not is_win: + # Ensure that 'python', 'pythonX' and 'pythonX.Y' all exist + py_exe_version_major = 'python%s' % sys.version_info[0] +- py_exe_version_major_minor = 'python%s.%s' % ( +- sys.version_info[0], sys.version_info[1]) ++ py_exe_version_major_minor = py_version + py_exe_no_version = 'python' + required_symlinks = [ py_exe_no_version, py_exe_version_major, + py_exe_version_major_minor ] +@@ -1547,7 +1547,8 @@ def fix_local_scheme(home_dir, symlink=True): + except ImportError: + pass + else: +- if sysconfig._get_default_scheme() == 'posix_local': ++ get_scheme = getattr(sysconfig, 'get_default_scheme', None) or sysconfig._get_default_scheme ++ if get_scheme() == 'posix_local': + local_path = os.path.join(home_dir, 'local') + if not os.path.exists(local_path): + os.mkdir(local_path) +@@ -1575,7 +1576,7 @@ def fix_lib64(lib_dir, symlink=True): + + logger.debug('This system uses lib64; symlinking lib64 to lib') + +- assert os.path.basename(lib_dir) == 'python%s' % sys.version[:3], ( ++ assert os.path.basename(lib_dir) == py_version, ( + "Unexpected python lib dir: %r" % lib_dir) + lib_parent = os.path.dirname(lib_dir) + top_level = os.path.dirname(lib_parent) +@@ -1637,7 +1638,7 @@ def make_environment_relocatable(home_dir): + fixup_pth_and_egg_link(home_dir) + ## FIXME: need to fix up distutils.cfg + +-OK_ABS_SCRIPTS = ['python', 'python%s' % sys.version[:3], ++OK_ABS_SCRIPTS = ['python', py_version, + 'activate', 'activate.bat', 'activate_this.py', + 'activate.fish', 'activate.csh'] + +@@ -1647,7 +1648,7 @@ def fixup_scripts(home_dir, bin_dir): + '%s /c' % os.path.normcase(os.environ.get('COMSPEC', 'cmd.exe')), + '', '.exe') + else: +- new_shebang_args = ('/usr/bin/env', sys.version[:3], '') ++ new_shebang_args = ('/usr/bin/env', version, '') + + # This is what we expect at the top of scripts: + shebang = '#!%s' % os.path.normcase(os.path.join( +diff --git a/virtualenv_embedded/activate_this.py b/virtualenv_embedded/activate_this.py +index f18193b..8272888 100644 +--- a/virtualenv_embedded/activate_this.py ++++ b/virtualenv_embedded/activate_this.py +@@ -19,7 +19,7 @@ base = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + if sys.platform == 'win32': + site_packages = os.path.join(base, 'Lib', 'site-packages') + else: +- site_packages = os.path.join(base, 'lib', 'python%s' % sys.version[:3], 'site-packages') ++ site_packages = os.path.join(base, 'lib', 'python%s.%s' % (sys.version_info[0], sys.version_info[1]), 'site-packages') + prev_sys_path = list(sys.path) + import site + site.addsitedir(site_packages) +diff --git a/virtualenv_embedded/site.py b/virtualenv_embedded/site.py +index 7969769..b3603ff 100644 +--- a/virtualenv_embedded/site.py ++++ b/virtualenv_embedded/site.py +@@ -134,7 +134,7 @@ def addbuilddir(): + """Append ./build/lib. in case we're running in the build dir + (especially for Guido :-)""" + from distutils.util import get_platform +- s = "build/lib.%s-%.3s" % (get_platform(), sys.version) ++ s = "build/lib.%s-%s.%s" % (get_platform(), sys.version_info[0], sys.version_info[1]) + if hasattr(sys, 'gettotalrefcount'): + s += '-pydebug' + s = os.path.join(os.path.dirname(sys.path[-1]), s) +@@ -162,7 +162,7 @@ def addpackage(sitedir, name, known_paths): + reset = 0 + fullname = os.path.join(sitedir, name) + try: +- f = open(fullname, "rU") ++ f = open(fullname, "r") + except IOError: + return + try: +@@ -222,21 +222,21 @@ def addsitepackages(known_paths, sys_prefix=sys.prefix, exec_prefix=sys.exec_pre + + if prefix.startswith("/System/Library/Frameworks/"): # Apple's Python + +- sitedirs = [os.path.join("/Library/Python", sys.version[:3], "site-packages"), ++ sitedirs = [os.path.join("/Library/Python", "%s.%s" % (sys.version_info[0], sys.version_info[1]), "site-packages"), + os.path.join(prefix, "Extras", "lib", "python")] + + else: # any other Python distros on OSX work this way + sitedirs = [os.path.join(prefix, "lib", +- "python" + sys.version[:3], "site-packages")] ++ "python" + "%s.%s" % (sys.version_info[0], sys.version_info[1]), "site-packages")] + + elif os.sep == '/': + sitedirs = [os.path.join(prefix, + "lib", +- "python" + sys.version[:3], ++ "python%s.%s" % (sys.version_info[0], sys.version_info[1]), + "site-packages"), + os.path.join(prefix, "lib", "site-python"), +- os.path.join(prefix, "python" + sys.version[:3], "lib-dynload")] +- lib64_dir = os.path.join(prefix, "lib64", "python" + sys.version[:3], "site-packages") ++ os.path.join(prefix, "python%s.%s" % (sys.version_info[0], sys.version_info[1]), "lib-dynload")] ++ lib64_dir = os.path.join(prefix, "lib64", "python%s.%s" % (sys.version_info[0], sys.version_info[1]), "site-packages") + if (os.path.exists(lib64_dir) and + os.path.realpath(lib64_dir) not in [os.path.realpath(p) for p in sitedirs]): + if _is_64bit: +@@ -251,11 +251,11 @@ def addsitepackages(known_paths, sys_prefix=sys.prefix, exec_prefix=sys.exec_pre + pass + # Debian-specific dist-packages directories: + sitedirs.append(os.path.join(prefix, "local/lib", +- "python" + sys.version[:3], ++ "python%s.%s" % (sys.version_info[0], sys.version_info[1]), + "dist-packages")) + if sys.version[0] == '2': + sitedirs.append(os.path.join(prefix, "lib", +- "python" + sys.version[:3], ++ "python%s.%s" % (sys.version_info[0], sys.version_info[1]), + "dist-packages")) + else: + sitedirs.append(os.path.join(prefix, "lib", +@@ -275,7 +275,7 @@ def addsitepackages(known_paths, sys_prefix=sys.prefix, exec_prefix=sys.exec_pre + os.path.join(home, + 'Library', + 'Python', +- sys.version[:3], ++ '%s.%s' % (sys.version_info[0], sys.version_info[1]), + 'site-packages')) + for sitedir in sitedirs: + if os.path.isdir(sitedir): +@@ -335,7 +335,7 @@ def addusersitepackages(known_paths): + else: + USER_BASE = joinuser(base, "Python") + USER_SITE = os.path.join(USER_BASE, +- "Python" + sys.version[0] + sys.version[2], ++ "Python%s%s" % (sys.version_info[0], sys.version_info[1]), + "site-packages") + else: + if env_base: +@@ -343,7 +343,7 @@ def addusersitepackages(known_paths): + else: + USER_BASE = joinuser("~", ".local") + USER_SITE = os.path.join(USER_BASE, "lib", +- "python" + sys.version[:3], ++ "python%s.%s" % (sys.version_info[0], sys.version_info[1]), + "site-packages") + + if ENABLE_USER_SITE and os.path.isdir(USER_SITE): +@@ -351,7 +351,7 @@ def addusersitepackages(known_paths): + if ENABLE_USER_SITE: + for dist_libdir in ("lib", "local/lib"): + user_site = os.path.join(USER_BASE, dist_libdir, +- "python" + sys.version[:3], ++ "python%s.%s" % (sys.version_info[0], sys.version_info[1]), + "dist-packages") + if os.path.isdir(user_site): + addsitedir(user_site, known_paths) +@@ -426,7 +426,7 @@ class _Printer(object): + for filename in self.__files: + filename = os.path.join(dir, filename) + try: +- fp = open(filename, "rU") ++ fp = open(filename, "r") + data = fp.read() + fp.close() + break +@@ -581,9 +581,9 @@ def virtual_install_main_packages(): + elif sys.platform == 'win32': + paths = [os.path.join(sys.real_prefix, 'Lib'), os.path.join(sys.real_prefix, 'DLLs')] + else: +- paths = [os.path.join(sys.real_prefix, 'lib', 'python'+sys.version[:3])] ++ paths = [os.path.join(sys.real_prefix, 'lib', 'python%s.%s' % (sys.version_info[0], sys.version_info[1]))] + hardcoded_relative_dirs = paths[:] # for the special 'darwin' case below +- lib64_path = os.path.join(sys.real_prefix, 'lib64', 'python'+sys.version[:3]) ++ lib64_path = os.path.join(sys.real_prefix, 'lib64', 'python%s.%s' % (sys.version_info[0], sys.version_info[1])) + if os.path.exists(lib64_path): + if _is_64bit: + paths.insert(0, lib64_path) +@@ -600,7 +600,7 @@ def virtual_install_main_packages(): + # This is a non-multiarch aware Python. Fallback to the old way. + arch = sys.platform + plat_path = os.path.join(sys.real_prefix, 'lib', +- 'python'+sys.version[:3], ++ 'python%s.%s' % (sys.version_info[0], sys.version_info[1]), + 'plat-%s' % arch) + if os.path.exists(plat_path): + paths.append(plat_path) diff --git a/SOURCES/python3.11-error.patch b/SOURCES/python3.11-error.patch new file mode 100644 index 0000000..46182db --- /dev/null +++ b/SOURCES/python3.11-error.patch @@ -0,0 +1,20 @@ +diff --git a/virtualenv.py b/virtualenv.py +index e5d0883..34d2160 100755 +--- a/virtualenv.py ++++ b/virtualenv.py +@@ -4,6 +4,15 @@ + import os + import sys + ++# The way virtualenv < 20 creates virtual environments ++# is not compatible with Python 3.11+ "frozen standard library modules" ++# https://docs.python.org/3.11/whatsnew/3.11.html#frozen-imports-static-code-objects ++if sys.version_info >= (3, 11): ++ venv_cmd = 'python{0.major}.{0.minor} -m venv'.format(sys.version_info) ++ sys.exit('ERROR: Virtual environments created by virtualenv < 20 ' ++ 'are not compatible with Python 3.11.\n' ++ 'ERROR: Use `{}` instead.'.format(venv_cmd)) ++ + # If we are running in a new interpreter to create a virtualenv, + # we do NOT want paths from our existing location interfering with anything, + # So we remove this file's directory from sys.path - most likely to be diff --git a/SPECS/python-virtualenv.spec b/SPECS/python-virtualenv.spec index eeaeb73..8cd0fd6 100644 --- a/SPECS/python-virtualenv.spec +++ b/SPECS/python-virtualenv.spec @@ -7,7 +7,7 @@ Name: python-virtualenv Version: 15.1.0 -Release: 21%{?dist} +Release: 22%{?dist} Summary: Tool to create isolated Python environments Group: Development/Languages @@ -32,6 +32,31 @@ Patch1: dont-fail-on-missing-certifi-cert.patch # 4. Use the importlib module rather than deprecated imp on Python 3 Patch2: rpm-wheels.patch +# Fixes for Python 3.10+ +# Backports from upstream virtualenv 16.7: +# +# Adjusts the code to accept Python minor versions with two (or more) digits +# https://github.com/pypa/virtualenv/commit/311a909c10 +# +# Use sysconfig.get_default_scheme() where available (added in Python 3.10) +# https://github.com/pypa/virtualenv/commit/b4aef0a53b +# +# Remove universal newline flag (removed in Python 3.11) +# https://github.com/pypa/virtualenv/commit/8b23c8296f +# +# Backports re-created from scratch, due to changes in formatting. +# +# Run bin/rebuild-script.py in %%build to regenerate the base64 embedded files! +Patch3: python3.10.patch + +# The way virtualenv < 20 creates virtual environments +# is not compatible with Python 3.11+ "frozen standard library modules" +# https://docs.python.org/3.11/whatsnew/3.11.html#frozen-imports-static-code-objects +# +# This patch makes virtualenv explicitly error and suggest venv instead. +# See https://bugzilla.redhat.com/show_bug.cgi?id=2165702 +Patch4: python3.11-error.patch + BuildArch: noarch %if %{with python2} @@ -143,6 +168,8 @@ licensed under an MIT-style permissive license %patch0 -p1 %patch1 -p1 %patch2 -p1 +%patch3 -p1 +%patch4 -p1 # Remove the wheels provided by RPM packages and argparse as it's only required for python 2.6 rm virtualenv_support/pip-* @@ -151,6 +178,10 @@ rm virtualenv_support/wheel-* rm virtualenv_support/argparse-* %build +# Regenerate base64 embedded files +%{?with_python2:%{__python2} bin/rebuild-script.py} +%{?with_python3:%{__python3} bin/rebuild-script.py} + # Build code %{?with_python2:%{py2_build}} @@ -239,6 +270,10 @@ fi %changelog +* Wed Feb 01 2023 Miro Hrončok - 15.1.0-22 +- Add a custom error message when users attempt to create Python 3.11+ virtual environments +- Resolves: rhbz#2165702 + * Wed Jul 28 2021 Tomas Orsava - 15.1.0-21 - Adjusted the postun scriptlets to enable upgrading to RHEL 9 - Resolves: rhbz#1933055