mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
Copy pip into the per test temporary location as well
Previously pip was always installed directly from the source tree however this causes concurrency issues so it is now copied into the temporary directory and installed from there.
This commit is contained in:
parent
86f5ebb4ca
commit
3095571d8f
3 changed files with 37 additions and 16 deletions
|
@ -3,7 +3,7 @@ import shutil
|
|||
import py
|
||||
import pytest
|
||||
|
||||
from tests.lib import TestData
|
||||
from tests.lib import SRC_DIR, TestData
|
||||
from tests.lib.path import Path
|
||||
from tests.lib.scripttest import PipTestEnvironment
|
||||
from tests.lib.venv import VirtualEnvironment
|
||||
|
@ -36,7 +36,23 @@ def virtualenv(tmpdir, monkeypatch):
|
|||
# Force shutil to use the older method of rmtree that didn't use the fd
|
||||
# functions. These seem to fail on Travis (and only on Travis).
|
||||
monkeypatch.setattr(shutil, "_use_fd_functions", False, raising=False)
|
||||
venv = VirtualEnvironment.create(tmpdir.join("workspace", "venv"))
|
||||
|
||||
# Copy over our source tree so that each virtual environment is self
|
||||
# contained
|
||||
pip_src = tmpdir.join("pip_src").abspath
|
||||
shutil.copytree(SRC_DIR, pip_src,
|
||||
ignore=shutil.ignore_patterns(
|
||||
"*.pyc", "docs/", "tests/", "pip.egg-info",
|
||||
),
|
||||
)
|
||||
|
||||
# Create the virtual environment
|
||||
venv = VirtualEnvironment.create(
|
||||
tmpdir.join("workspace", "venv"),
|
||||
pip_source_dir=pip_src,
|
||||
)
|
||||
|
||||
# Undo our monkeypatching of shutil
|
||||
monkeypatch.undo()
|
||||
|
||||
return venv
|
||||
|
|
|
@ -210,7 +210,7 @@ class TestUpgradeSetuptools(object):
|
|||
note: virtualenv-1.10 contains setuptools-0.9.7
|
||||
"""
|
||||
|
||||
def prep_ve(self, script, version, distribute=False):
|
||||
def prep_ve(self, script, version, pip_src, distribute=False):
|
||||
self.script = script
|
||||
self.script.pip_install_local('virtualenv==%s' %version)
|
||||
args = ['virtualenv', self.script.scratch_path/'VE']
|
||||
|
@ -222,41 +222,44 @@ class TestUpgradeSetuptools(object):
|
|||
self.script.run(*args)
|
||||
self.ve_bin = self.script.scratch_path/'VE'/'bin'
|
||||
self.script.run(self.ve_bin/'pip', 'uninstall', '-y', 'pip')
|
||||
self.script.run(self.ve_bin/'python', 'setup.py', 'develop', cwd=SRC_DIR, expect_stderr=True)
|
||||
self.script.run(self.ve_bin/'python', 'setup.py', 'install',
|
||||
cwd=pip_src,
|
||||
expect_stderr=True,
|
||||
)
|
||||
|
||||
@pytest.mark.skipif("sys.version_info >= (3,0)")
|
||||
def test_py2_from_setuptools_6_to_setuptools_7(self, script, data):
|
||||
self.prep_ve(script, '1.9.1')
|
||||
def test_py2_from_setuptools_6_to_setuptools_7(self, script, data, virtualenv):
|
||||
self.prep_ve(script, '1.9.1', virtualenv.pip_source_dir)
|
||||
result = self.script.run(self.ve_bin/'pip', 'install', '--no-index', '--find-links=%s' % data.find_links, '-U', 'setuptools')
|
||||
assert "Found existing installation: setuptools 0.6c11" in result.stdout
|
||||
result = self.script.run(self.ve_bin/'pip', 'list')
|
||||
"setuptools (0.9.8)" in result.stdout
|
||||
|
||||
def test_py2_py3_from_distribute_6_to_setuptools_7(self, script, data):
|
||||
self.prep_ve(script, '1.9.1', distribute=True)
|
||||
def test_py2_py3_from_distribute_6_to_setuptools_7(self, script, data, virtualenv):
|
||||
self.prep_ve(script, '1.9.1', virtualenv.pip_source_dir, distribute=True)
|
||||
result = self.script.run(self.ve_bin/'pip', 'install', '--no-index', '--find-links=%s' % data.find_links, '-U', 'setuptools')
|
||||
assert "Found existing installation: distribute 0.6.34" in result.stdout
|
||||
result = self.script.run(self.ve_bin/'pip', 'list')
|
||||
"setuptools (0.9.8)" in result.stdout
|
||||
"distribute (0.7.3)" in result.stdout
|
||||
|
||||
def test_from_setuptools_7_to_setuptools_7(self, script, data):
|
||||
self.prep_ve(script, '1.10')
|
||||
def test_from_setuptools_7_to_setuptools_7(self, script, data, virtualenv):
|
||||
self.prep_ve(script, '1.10', virtualenv.pip_source_dir)
|
||||
result = self.script.run(self.ve_bin/'pip', 'install', '--no-index', '--find-links=%s' % data.find_links, '-U', 'setuptools')
|
||||
assert "Found existing installation: setuptools 0.9.7" in result.stdout
|
||||
result = self.script.run(self.ve_bin/'pip', 'list')
|
||||
"setuptools (0.9.8)" in result.stdout
|
||||
|
||||
def test_from_setuptools_7_to_setuptools_7_using_wheel(self, script, data):
|
||||
self.prep_ve(script, '1.10')
|
||||
def test_from_setuptools_7_to_setuptools_7_using_wheel(self, script, data, virtualenv):
|
||||
self.prep_ve(script, '1.10', virtualenv.pip_source_dir)
|
||||
result = self.script.run(self.ve_bin/'pip', 'install', '--use-wheel', '--no-index', '--find-links=%s' % data.find_links, '-U', 'setuptools')
|
||||
assert "Found existing installation: setuptools 0.9.7" in result.stdout
|
||||
assert 'setuptools-0.9.8.dist-info' in str(result.files_created) #only wheels use dist-info
|
||||
result = self.script.run(self.ve_bin/'pip', 'list')
|
||||
"setuptools (0.9.8)" in result.stdout
|
||||
|
||||
def test_from_setuptools_7_to_setuptools_7_with_distribute_7_installed(self, script, data):
|
||||
self.prep_ve(script, '1.9.1', distribute=True)
|
||||
def test_from_setuptools_7_to_setuptools_7_with_distribute_7_installed(self, script, data, virtualenv):
|
||||
self.prep_ve(script, '1.9.1', virtualenv.pip_source_dir, distribute=True)
|
||||
result = self.script.run(self.ve_bin/'pip', 'install', '--no-index', '--find-links=%s' % data.find_links, '-U', 'setuptools')
|
||||
result = self.script.run(self.ve_bin/'pip', 'install', '--no-index', '--find-links=%s' % data.find_links, 'setuptools==0.9.6')
|
||||
result = self.script.run(self.ve_bin/'pip', 'list')
|
||||
|
|
|
@ -23,6 +23,7 @@ class VirtualEnvironment(object):
|
|||
|
||||
def __init__(self, location, *args, **kwargs):
|
||||
self.location = Path(location)
|
||||
self.pip_source_dir = kwargs.pop("pip_source_dir")
|
||||
self._system_site_packages = kwargs.pop("system_site_packages", False)
|
||||
|
||||
super(VirtualEnvironment, self).__init__(*args, **kwargs)
|
||||
|
@ -31,8 +32,8 @@ class VirtualEnvironment(object):
|
|||
return "<VirtualEnvironment {}>".format(self.location)
|
||||
|
||||
@classmethod
|
||||
def create(cls, location, clear=False):
|
||||
obj = cls(location)
|
||||
def create(cls, location, clear=False, pip_source_dir=None):
|
||||
obj = cls(location, pip_source_dir=pip_source_dir)
|
||||
obj._create(clear=clear)
|
||||
return obj
|
||||
|
||||
|
@ -49,6 +50,7 @@ class VirtualEnvironment(object):
|
|||
# environment
|
||||
p = subprocess.Popen(
|
||||
[self.location.join("bin", "python"), "setup.py", "develop"],
|
||||
cwd=self.pip_source_dir,
|
||||
stderr=subprocess.STDOUT,
|
||||
stdout=DEVNULL,
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue