|
|
feb75d |
diff --git a/tests/test_virtualenv.py b/tests/test_virtualenv.py
|
|
|
feb75d |
index ce45ede..7946a16 100644
|
|
|
feb75d |
--- a/tests/test_virtualenv.py
|
|
|
feb75d |
+++ b/tests/test_virtualenv.py
|
|
|
feb75d |
@@ -4,11 +4,16 @@ import os
|
|
|
feb75d |
import shutil
|
|
|
feb75d |
import sys
|
|
|
feb75d |
import tempfile
|
|
|
feb75d |
+import zipfile
|
|
|
feb75d |
import pytest
|
|
|
feb75d |
import platform # noqa
|
|
|
feb75d |
|
|
|
feb75d |
from mock import patch, Mock
|
|
|
feb75d |
|
|
|
feb75d |
+try:
|
|
|
feb75d |
+ from pathlib import Path
|
|
|
feb75d |
+except ImportError:
|
|
|
feb75d |
+ from pathlib2 import Path
|
|
|
feb75d |
|
|
|
feb75d |
def test_version():
|
|
|
feb75d |
"""Should have a version string"""
|
|
|
feb75d |
@@ -139,3 +144,44 @@ def test_always_copy_option():
|
|
|
feb75d |
" symlink (to %s)" % (full_name, os.readlink(full_name))
|
|
|
feb75d |
finally:
|
|
|
feb75d |
shutil.rmtree(tmp_virtualenv)
|
|
|
feb75d |
+
|
|
|
feb75d |
+
|
|
|
feb75d |
+def test_missing_certifi_pem(tmp_path):
|
|
|
feb75d |
+ """Make sure that we can still create virtual environment if pip is
|
|
|
feb75d |
+ patched to not use certifi's cacert.pem and the file is removed.
|
|
|
feb75d |
+ This can happen if pip is packaged by Linux distributions."""
|
|
|
feb75d |
+ proj_dir = Path(__file__).parent.parent
|
|
|
feb75d |
+ support_original = proj_dir / "virtualenv_support"
|
|
|
feb75d |
+ pip_wheel = sorted(support_original.glob("pip*whl"))[0]
|
|
|
feb75d |
+ whl_name = pip_wheel.name
|
|
|
feb75d |
+
|
|
|
feb75d |
+ wheeldir = tmp_path / "wheels"
|
|
|
feb75d |
+ wheeldir.mkdir()
|
|
|
feb75d |
+ tmpcert = tmp_path / "tmpcert.pem"
|
|
|
feb75d |
+ cacert = "pip/_vendor/requests/cacert.pem"
|
|
|
feb75d |
+ certifi = "pip/_vendor/requests/certs.py"
|
|
|
feb75d |
+ oldpath = b"os.path.join(os.path.dirname(__file__), 'cacert.pem')"
|
|
|
feb75d |
+ newpath = "r'{}'".format(tmpcert).encode()
|
|
|
feb75d |
+ removed = False
|
|
|
feb75d |
+ replaced = False
|
|
|
feb75d |
+
|
|
|
feb75d |
+ with zipfile.ZipFile(str(pip_wheel), "r") as whlin:
|
|
|
feb75d |
+ with zipfile.ZipFile(str(wheeldir / whl_name), "w") as whlout:
|
|
|
feb75d |
+ for item in whlin.infolist():
|
|
|
feb75d |
+ buff = whlin.read(item.filename)
|
|
|
feb75d |
+ if item.filename == cacert:
|
|
|
feb75d |
+ tmpcert.write_bytes(buff)
|
|
|
feb75d |
+ removed = True
|
|
|
feb75d |
+ continue
|
|
|
feb75d |
+ if item.filename == certifi:
|
|
|
feb75d |
+ nbuff = buff.replace(oldpath, newpath)
|
|
|
feb75d |
+ assert nbuff != buff
|
|
|
feb75d |
+ buff = nbuff
|
|
|
feb75d |
+ replaced = True
|
|
|
feb75d |
+ whlout.writestr(item, buff)
|
|
|
feb75d |
+
|
|
|
feb75d |
+ assert removed and replaced
|
|
|
feb75d |
+
|
|
|
feb75d |
+ venvdir = tmp_path / "venv"
|
|
|
feb75d |
+ search_dirs = [str(wheeldir), str(support_original)]
|
|
|
feb75d |
+ virtualenv.create_environment(str(venvdir), search_dirs=search_dirs)
|
|
|
feb75d |
diff --git a/virtualenv.egg-info/PKG-INFO b/virtualenv.egg-info/PKG-INFO
|
|
|
feb75d |
index 11f5c75..501e81a 100644
|
|
|
feb75d |
--- a/virtualenv.egg-info/PKG-INFO
|
|
|
feb75d |
+++ b/virtualenv.egg-info/PKG-INFO
|
|
|
feb75d |
@@ -1,10 +1,12 @@
|
|
|
feb75d |
-Metadata-Version: 1.1
|
|
|
feb75d |
+Metadata-Version: 1.2
|
|
|
feb75d |
Name: virtualenv
|
|
|
feb75d |
Version: 15.1.0
|
|
|
feb75d |
Summary: Virtual Python Environment builder
|
|
|
feb75d |
Home-page: https://virtualenv.pypa.io/
|
|
|
feb75d |
-Author: Jannis Leidel, Carl Meyer and Brian Rosner
|
|
|
feb75d |
-Author-email: python-virtualenv@groups.google.com
|
|
|
feb75d |
+Author: Ian Bicking
|
|
|
feb75d |
+Author-email: ianb@colorstudy.com
|
|
|
feb75d |
+Maintainer: Jannis Leidel, Carl Meyer and Brian Rosner
|
|
|
feb75d |
+Maintainer-email: python-virtualenv@groups.google.com
|
|
|
feb75d |
License: MIT
|
|
|
feb75d |
Description: Virtualenv
|
|
|
feb75d |
==========
|
|
|
feb75d |
diff --git a/virtualenv.py b/virtualenv.py
|
|
|
feb75d |
index a174b8a..5699998 100755
|
|
|
feb75d |
--- a/virtualenv.py
|
|
|
feb75d |
+++ b/virtualenv.py
|
|
|
feb75d |
@@ -861,7 +861,10 @@ def install_wheel(project_names, py_executable, search_dirs=None,
|
|
|
feb75d |
|
|
|
feb75d |
import pip
|
|
|
feb75d |
|
|
|
feb75d |
- cert_data = pkgutil.get_data("pip._vendor.requests", "cacert.pem")
|
|
|
feb75d |
+ try:
|
|
|
feb75d |
+ cert_data = pkgutil.get_data("pip._vendor.requests", "cacert.pem")
|
|
|
feb75d |
+ except IOError:
|
|
|
feb75d |
+ cert_data = None
|
|
|
feb75d |
if cert_data is not None:
|
|
|
feb75d |
cert_file = tempfile.NamedTemporaryFile(delete=False)
|
|
|
feb75d |
cert_file.write(cert_data)
|