summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorholger krekel <holger@merlinux.eu>2013-08-13 23:34:12 +0200
committerholger krekel <holger@merlinux.eu>2013-08-13 23:34:12 +0200
commit561f7d3a0809b289ddb6622fb710eb19965f761a (patch)
treeac995f6c3a9c4d871448b966e026e621d984f26c
parentc08e799a9e7cd799f6862839baabaae9b361f73b (diff)
downloadtox-561f7d3a0809b289ddb6622fb710eb19965f761a.tar.gz
during installation of packages HOME is now set to a pseudo
location (envtmpdir/pseudo-home). Also, if an index url was specified a .pydistutils.cfg file will be written so that index_url is set if a package contains a ``setup_requires``.
-rwxr-xr-xCHANGELOG5
-rw-r--r--setup.py2
-rw-r--r--tests/test_venv.py13
-rw-r--r--tox/__init__.py2
-rw-r--r--tox/_venv.py34
5 files changed, 50 insertions, 6 deletions
diff --git a/CHANGELOG b/CHANGELOG
index e00df39..d7f17a7 100755
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,11 @@
1.6.0.dev
-----------------
+- during installation of dependencies HOME is set to a pseudo
+ location (envtmpdir/pseudo-home). If an index url was specified
+ a .pydistutils.cfg file will be written so that index_url
+ is set if a package contains a ``setup_requires``.
+
- remove toxbootstrap.py for now because it is broken.
- fix issue35: add new "install_command" testenv-option to configure the
diff --git a/setup.py b/setup.py
index 731c04e..f286a4f 100644
--- a/setup.py
+++ b/setup.py
@@ -28,7 +28,7 @@ def main():
description='virtualenv-based automation of test activities',
long_description=open("README.rst").read(),
url='http://tox.testrun.org/',
- version='1.6rc1',
+ version='1.6rc2',
license='http://opensource.org/licenses/MIT',
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
author='holger krekel',
diff --git a/tests/test_venv.py b/tests/test_venv.py
index 983d93c..7193826 100644
--- a/tests/test_venv.py
+++ b/tests/test_venv.py
@@ -611,3 +611,16 @@ def test_command_relative_issue26(newmocksession, tmpdir, monkeypatch):
monkeypatch.setenv("PATH", str(tmpdir))
x4 = venv.getcommandpath("x", cwd=tmpdir)
mocksession.report.expect("warning", "*test command found but not*")
+
+def test_hack_home_env(tmpdir):
+ from tox._venv import hack_home_env
+ env = hack_home_env(tmpdir, "http://index")
+ assert env["HOME"] == str(tmpdir)
+ assert env["PIP_INDEX_URL"] == "http://index"
+ assert "index_url = http://index" in \
+ tmpdir.join(".pydistutils.cfg").read()
+ tmpdir.remove()
+ env = hack_home_env(tmpdir, None)
+ assert env["HOME"] == str(tmpdir)
+ assert not tmpdir.join(".pydistutils.cfg").check()
+ assert "PIP_INDEX_URL" not in env
diff --git a/tox/__init__.py b/tox/__init__.py
index 90012e1..145a89d 100644
--- a/tox/__init__.py
+++ b/tox/__init__.py
@@ -1,5 +1,5 @@
#
-__version__ = '1.6rc1'
+__version__ = '1.6rc2'
class exception:
class Error(Exception):
diff --git a/tox/_venv.py b/tox/_venv.py
index 43178c7..fb0450d 100644
--- a/tox/_venv.py
+++ b/tox/_venv.py
@@ -266,7 +266,8 @@ class VirtualEnv(object):
l.append("--download-cache=%s" % self.envconfig.downloadcache)
return l
- def run_install_command(self, args, indexserver=None, action=None):
+ def run_install_command(self, args, indexserver=None, action=None,
+ extraenv=None):
argv = self.envconfig.install_command_argv[:]
# use pip-script on win32 to avoid the executable locking
if argv[0] == "pip" and sys.platform == "win32":
@@ -282,8 +283,10 @@ class VirtualEnv(object):
except KeyError:
pass
env = dict(PYTHONIOENCODING='utf_8')
- self._pcall(argv, cwd=self.envconfig.envlogdir, extraenv=env,
- action=action)
+ if extraenv is not None:
+ env.update(extraenv)
+ self._pcall(argv, cwd=self.envconfig.envlogdir,
+ extraenv=env, action=action)
def _install(self, deps, extraopts=None, action=None):
if not deps:
@@ -305,8 +308,12 @@ class VirtualEnv(object):
extraopts = extraopts or []
for ixserver in l:
+ extraenv = hack_home_env(
+ homedir=self.envconfig.envtmpdir.join("pseudo-home"),
+ index_url = ixserver.url)
args = d[ixserver] + extraopts
- self.run_install_command(args, ixserver.url, action)
+ self.run_install_command(args, ixserver.url, action,
+ extraenv=extraenv)
def _getenv(self):
env = self.envconfig.setenv
@@ -415,3 +422,22 @@ else:
# Python launcher py.exe
if m:
locate_via_py(*m.groups())
+
+
+def hack_home_env(homedir, index_url):
+ # XXX HACK (this could also live with tox itself, consider)
+ # if tox uses pip on a package that requires setup_requires
+ # the index url set with pip is usually not recognized
+ # because it is setuptools executing very early.
+ # We therefore run the tox command in an artifical home
+ # directory and set .pydistutils.cfg and pip.conf files
+ # accordingly.
+ if not homedir.check():
+ homedir.ensure(dir=1)
+ d = dict(HOME=str(homedir))
+ if index_url:
+ homedir.join(".pydistutils.cfg").write(
+ "[easy_install]\n"
+ "index_url = %s\n" % index_url)
+ d["PIP_INDEX_URL"] = index_url
+ return d