Miro Hrončok 6 years ago
parent 5251bc6300
commit c2c5bce7b0

1
.gitignore vendored

@ -4,3 +4,4 @@
noarch
/virtualenv-15.1.0.tar.gz
/virtualenv-16.0.0.tar.gz
/virtualenv-16.6.1.tar.gz

@ -1,16 +0,0 @@
diff --git a/virtualenv.py b/virtualenv.py
index c4e3bd5..89b8863 100755
--- a/virtualenv.py
+++ b/virtualenv.py
@@ -1181,8 +1181,9 @@ def install_python(home_dir, lib_dir, inc_dir, bin_dir, site_packages, clear, sy
exec_dir = join(sys.exec_prefix, 'Lib')
else:
exec_dir = join(sys.exec_prefix, 'lib', py_version)
- for fn in os.listdir(exec_dir):
- copyfile(join(exec_dir, fn), join(lib_dir, fn), symlink)
+ if os.path.isdir(exec_dir):
+ for fn in os.listdir(exec_dir):
+ copyfile(join(exec_dir, fn), join(lib_dir, fn), symlink)
if is_jython:
# Jython has either jython-dev.jar and javalib/ dir, or just

@ -1,79 +0,0 @@
diff --git a/tests/test_virtualenv.py b/tests/test_virtualenv.py
index ce45ede..3cd200b 100644
--- a/tests/test_virtualenv.py
+++ b/tests/test_virtualenv.py
@@ -4,11 +4,16 @@ import os
import shutil
import sys
import tempfile
+import zipfile
import pytest
import platform # noqa
from mock import patch, Mock
+try:
+ from pathlib import Path
+except ImportError:
+ from pathlib2 import Path
def test_version():
"""Should have a version string"""
@@ -139,3 +144,44 @@ def test_always_copy_option():
" symlink (to %s)" % (full_name, os.readlink(full_name))
finally:
shutil.rmtree(tmp_virtualenv)
+
+
+def test_missing_certifi_pem(tmp_path):
+ """Make sure that we can still create virtual environment if pip is
+ patched to not use certifi's cacert.pem and the file is removed.
+ This can happen if pip is packaged by Linux distributions."""
+ proj_dir = Path(__file__).parent.parent
+ support_original = proj_dir / "virtualenv_support"
+ pip_wheel = sorted(support_original.glob("pip*whl"))[0]
+ whl_name = pip_wheel.name
+
+ wheeldir = tmp_path / "wheels"
+ wheeldir.mkdir()
+ tmpcert = tmp_path / "tmpcert.pem"
+ cacert = "pip/_vendor/certifi/cacert.pem"
+ certifi = "pip/_vendor/certifi/core.py"
+ oldpath = b"os.path.join(f, 'cacert.pem')"
+ newpath = "r'{}'".format(tmpcert).encode()
+ removed = False
+ replaced = False
+
+ with zipfile.ZipFile(str(pip_wheel), "r") as whlin:
+ with zipfile.ZipFile(str(wheeldir / whl_name), "w") as whlout:
+ for item in whlin.infolist():
+ buff = whlin.read(item.filename)
+ if item.filename == cacert:
+ tmpcert.write_bytes(buff)
+ removed = True
+ continue
+ if item.filename == certifi:
+ nbuff = buff.replace(oldpath, newpath)
+ assert nbuff != buff
+ buff = nbuff
+ replaced = True
+ whlout.writestr(item, buff)
+
+ assert removed and replaced
+
+ venvdir = tmp_path / "venv"
+ search_dirs = [str(wheeldir), str(support_original)]
+ virtualenv.create_environment(str(venvdir), search_dirs=search_dirs)
diff --git a/virtualenv.py b/virtualenv.py
index c1fe7f1..3837250 100755
--- a/virtualenv.py
+++ b/virtualenv.py
@@ -867,6 +867,8 @@ def install_wheel(project_names, py_executable, search_dirs=None,
except ImportError:
from pip import main as _main
cert_data = pkgutil.get_data("pip._vendor.requests", "cacert.pem")
+ except IOError:
+ cert_data = None
if cert_data is not None:
cert_file = tempfile.NamedTemporaryFile(delete=False)

@ -0,0 +1,37 @@
From 01e27bd7a6ddde4db6654ab2f18def36dab64329 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
Date: Fri, 12 Jul 2019 11:58:32 +0200
Subject: [PATCH] Also search the LICENSE file in lib64/pythonX.Y
Several Linux distributions including Gentoo, Fedora, openSUSE
put things in lib64/pythonX.Y instead of lib/pythonX.Y on 64bit
architectures (x86_64, aarch64, etc.).
This was already respected via the fix_lib64() function, however
when virtualenv was searching for Python LICENSE, it was not.
Now is the lib64/pythonX.Y patch searched as well and unlike fix_lib64()
no checks need to be made, as the patch are tested in sequence.
See https://github.com/pypa/virtualenv/issues/1352#issuecomment-510500384
---
virtualenv.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/virtualenv.py b/virtualenv.py
index 3ccbed6d..d4d5d304 100755
--- a/virtualenv.py
+++ b/virtualenv.py
@@ -1333,9 +1333,12 @@ def copy_required_files(src_dir, lib_dir, symlink):
def copy_license(prefix, dst_prefix, lib_dir, symlink):
"""Copy the license file so `license()` builtin works"""
+ lib64_dir = lib_dir.replace("lib", "lib64")
for license_path in (
# posix cpython
os.path.join(prefix, os.path.relpath(lib_dir, dst_prefix), "LICENSE.txt"),
+ # posix cpython installed in /usr/lib64
+ os.path.join(prefix, os.path.relpath(lib64_dir, dst_prefix), "LICENSE.txt"),
# windows cpython
os.path.join(prefix, "LICENSE.txt"),
# pypy

@ -1,30 +1,18 @@
Name: python-virtualenv
Version: 16.0.0
Release: 7%{?dist}
Version: 16.6.1
Release: 1%{?dist}
Summary: Tool to create isolated Python environments
License: MIT
URL: http://pypi.python.org/pypi/virtualenv
Source0: http://pypi.python.org/packages/source/v/virtualenv/virtualenv-%{version}.tar.gz
# virtualenv -p "/usr/bin/python3" venv fails if there are not packages installed
# under /usr/local/lib/pythonX.Y/site-packages. Check if exec_dir exists before
# listing it's content.
Patch0: check-exec_dir.patch
# virtualenv 16.x dropped support for Python 2.6 yet we still advertise that
# so we bring it back
# https://bugzilla.redhat.com/show_bug.cgi?id=1602347
# once an virtualenv update has to be made that will make this impossible,
# the change needs to be properly communicated with Python SIG!
Patch1: python26.patch
Source0: %{pypi_source virtualenv}
# Add /usr/share/python-wheels to file_search_dirs
Patch2: rpm-wheels.patch
Patch1: 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
# Fix search patch for the Python LICENSE file on 64bit systems
# Proposed upstream: https://github.com/pypa/virtualenv/pull/1382
Patch2: lib64-license.patch
BuildArch: noarch
BuildRequires: git-core
@ -32,9 +20,16 @@ BuildRequires: python2-devel
BuildRequires: python2-setuptools
BuildRequires: python3-devel
BuildRequires: python3-sphinx
BuildRequires: python3-setuptools
# docs need towncrier and that is not yet available when bootstrapping Python
%bcond_without docs
%if %{with docs}
BuildRequires: python3-sphinx
BuildRequires: python3-sphinx_rtd_theme
BuildRequires: python3-towncrier
%endif
# RPM installed wheels
BuildRequires: python-pip-wheel
BuildRequires: python-setuptools-wheel
@ -51,8 +46,7 @@ licensed under an MIT-style permissive license.
Summary: Tool to create isolated Python environments
Requires: python2-setuptools
Requires: python2-devel
Requires: (python2-virtualenv-python26 = %{version}-%{release} if python26)
Obsoletes: python2-virtualenv-python26 < 16.6
%{?python_provide:%python_provide python2-virtualenv}
# RPM installed wheels
@ -67,34 +61,13 @@ written by Ian Bicking, and sponsored by the Open Planning Project. It is
licensed under an MIT-style permissive license
%package -n python2-virtualenv-python26
Summary: Extra bits of virtuelenv only needed with Python 2.6
Requires: python2-virtualenv = %{version}-%{release}
%{?python_provide:%python_provide python2-virtualenv-python26}
# bundled wheels for Python 2.6
Provides: bundled(python2dist(argparse)) = 1.4.0
Provides: bundled(python2dist(pip)) = 9.0.3
Provides: bundled(python2dist(setuptools)) = 36.8.0
Provides: bundled(python2dist(wheel)) = 0.29.0
%description -n python2-virtualenv-python26
This package contains wheels of older versions of argparse, pip, setuptools and
wheel that are required for virtualenv to create Python 2.6 virtual
environments.
%package -n python3-virtualenv
Summary: Tool to create isolated Python environments
Requires: python3-setuptools
Requires: python3-devel
Requires: (python3-virtualenv-python26 = %{version}-%{release} if python26)
Obsoletes: python3-virtualenv-python26 < 16.6
%{?python_provide:%python_provide python3-virtualenv}
# /usr/bin/virtualenv was moved (remove in F31)
Conflicts: python2-virtualenv < 16.0.0-5
# Provide "virtualenv" for convenience
Provides: virtualenv = %{version}-%{release}
@ -110,28 +83,13 @@ written by Ian Bicking, and sponsored by the Open Planning Project. It is
licensed under an MIT-style permissive license
%package -n python3-virtualenv-python26
Summary: Extra bits of virtuelenv only needed with Python 2.6
Requires: python3-virtualenv = %{version}-%{release}
%{?python_provide:%python_provide python3-virtualenv-python26}
# bundled wheels for Python 2.6
Provides: bundled(python2dist(argparse)) = 1.4.0
Provides: bundled(python2dist(pip)) = 9.0.3
Provides: bundled(python2dist(setuptools)) = 36.8.0
Provides: bundled(python2dist(wheel)) = 0.29.0
%description -n python3-virtualenv-python26
This package contains wheels of older versions of argparse, pip, setuptools and
wheel that are required for virtualenv to create Python 2.6 virtual
environments.
%if %{with docs}
%package -n python-virtualenv-doc
Summary: Documentation for python virtualenv
%description -n python-virtualenv-doc
Documentation for python virtualenv.
%endif
%prep
@ -139,14 +97,12 @@ Documentation for python virtualenv.
%{__sed} -i -e "1s|#!/usr/bin/env python||" virtualenv.py
# Remove the wheels provided by RPM packages
# Those are the "recent" version shipped with virtualenv 16.0.0
rm virtualenv_support/pip-10.*
rm virtualenv_support/setuptools-39.*
rm virtualenv_support/wheel-0.31.*
# Those are the "recent" version shipped with virtualenv 16.6.1
rm virtualenv_support/pip-*
rm virtualenv_support/setuptools-*
rm virtualenv_support/wheel-*
# make sure we only left what was intended (old argparse, pip, setuptools, wheel)
ls virtualenv_support/*.whl
test $(ls virtualenv_support/*.whl -1 | wc -l) -eq 4
test ! -f virtualenv_support/*.whl
%build
# Build code
@ -154,8 +110,10 @@ test $(ls virtualenv_support/*.whl -1 | wc -l) -eq 4
%{py3_build}
# Build docs
%if %{with docs}
%{__python3} setup.py build_sphinx
rm -f build/sphinx/html/.buildinfo
%endif
%install
# As https://bugzilla.redhat.com/show_bug.cgi?id=1599422 we ship binaries in py3
@ -168,19 +126,11 @@ rm %{buildroot}/%{_bindir}/virtualenv
%files -n python2-virtualenv
%license LICENSE.txt
%doc docs/*rst PKG-INFO AUTHORS.txt
%{python2_sitelib}/virtualenv.py*
%dir %{python2_sitelib}/virtualenv_support/
%{python2_sitelib}/virtualenv_support/__init__.py*
%{python2_sitelib}/virtualenv-*.egg-info/
%files -n python2-virtualenv-python26
%{python2_sitelib}/virtualenv_support/*.whl
# Include sphinx docs on Fedora
%files -n python-virtualenv-doc
%doc build/sphinx/*
%files -n python3-virtualenv
%license LICENSE.txt
%doc docs/*rst PKG-INFO AUTHORS.txt
@ -192,12 +142,18 @@ rm %{buildroot}/%{_bindir}/virtualenv
%{python3_sitelib}/virtualenv-*.egg-info/
%{python3_sitelib}/__pycache__/*
%files -n python3-virtualenv-python26
%{python3_sitelib}/virtualenv_support/*.whl
%if %{with docs}
%files -n python-virtualenv-doc
%doc build/sphinx/*
%endif
%changelog
* Thu Jul 11 2019 Miro Hrončok <mhroncok@redhat.com> - 16.6.1-1
- Update to 16.6.1 (#1699031)
- No more Python 2.6 or Jython support
- Drop runtime dependency on pythonX-devel
* Sat Feb 02 2019 Fedora Release Engineering <releng@fedoraproject.org> - 16.0.0-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild

File diff suppressed because it is too large Load Diff

@ -1,14 +1,16 @@
diff --git a/virtualenv.py b/virtualenv.py
index 2ad2695..a0ddfaf 100755
index 3ccbed6..504efc8 100755
--- a/virtualenv.py
+++ b/virtualenv.py
@@ -400,6 +400,9 @@ def _find_file(filename, dirs):
def file_search_dirs():
here = os.path.dirname(os.path.abspath(__file__))
dirs = [here, join(here, 'virtualenv_support')]
+ if sys.version_info >= (2, 7):
+ # we don't insert on 2.6 because the wheels there are not compatible
+ dirs.insert(1, '/usr/share/python-wheels')
if os.path.splitext(os.path.dirname(__file__))[0] != 'virtualenv':
# Probably some boot script; just in case virtualenv is installed...
@@ -473,7 +473,10 @@ def virtualenv_support_dirs():
# normal filesystem installation
if os.path.isdir(join(HERE, "virtualenv_support")):
- yield [join(HERE, "virtualenv_support")]
+ if os.path.isdir("/usr/share/python-wheels"):
+ yield ["/usr/share/python-wheels", join(HERE, "virtualenv_support")]
+ else:
+ yield [join(HERE, "virtualenv_support")]
elif IS_ZIPAPP:
tmpdir = tempfile.mkdtemp()
try:

@ -1 +1 @@
SHA512 (virtualenv-16.0.0.tar.gz) = 43bc37f1da1b65e9a2df5a8813a801f27f5783b7211219d441d1c2132789917df42fdc0aba1d5ec51e3d6f7583af9474d59c1f532d8880c8c325ccc96e73b3df
SHA512 (virtualenv-16.6.1.tar.gz) = 6253f44401471b6af09b38cbb3919fc35070e3168d5381c384011028e75e2ded6d13dc86304eb97b13c302ac917396727e4a6f6d0c98aa9eea885391af760620

@ -8,9 +8,6 @@
- repo: "https://src.fedoraproject.org/tests/python.git"
dest: "python"
tests:
- smoke26:
dir: python/smoke
run: VERSION=2.6 METHOD=virtualenv TOX=false ./venv.sh
- smoke27:
dir: python/smoke
run: VERSION=2.7 METHOD=virtualenv ./venv.sh
@ -32,7 +29,6 @@
required_packages:
- gcc
- virtualenv
- python26
- python27
- python34
- python35

Loading…
Cancel
Save