Commits

holger krekel committed 6aec60d

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``.

Comments (0)

Files changed (5)

 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
         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',

tests/test_venv.py

     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
 #
-__version__ = '1.6rc1'
+__version__ = '1.6rc2'
 
 class exception:
     class Error(Exception):
             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":
             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:
 
         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
         # 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