summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorholger krekel <holger@merlinux.eu>2015-06-18 16:07:13 +0200
committerholger krekel <holger@merlinux.eu>2015-06-18 16:07:13 +0200
commit8602c192146a66b029919619ca32e2465546e6e0 (patch)
treea69d22507be3805551dd81835ad665f6a45aadd5
parent0c82e9c32d2f0b1209967f774325f0f780f83e97 (diff)
downloadtox-8602c192146a66b029919619ca32e2465546e6e0.tar.gz
remove --set-home option which probably nobody used and was hackily implemented
-rw-r--r--CHANGELOG5
-rw-r--r--tests/test_venv.py45
-rw-r--r--tox/config.py12
-rw-r--r--tox/venv.py45
4 files changed, 16 insertions, 91 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 3ba97d7..8009a32 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -4,6 +4,11 @@
- fix issue258, fix issue248, fix issue253: for non-test commands
(installation, venv creation) we pass in the full invocation environment.
+- remove experimental --set-home option which was hardly used and
+ hackily implemented (if people want home-directory isolation we should
+ figure out a better way to do it, possibly through a plugin)
+
+
2.0.2
----------
diff --git a/tests/test_venv.py b/tests/test_venv.py
index 37b0f50..f1574b1 100644
--- a/tests/test_venv.py
+++ b/tests/test_venv.py
@@ -619,48 +619,3 @@ def test_command_relative_issue26(newmocksession, tmpdir, monkeypatch):
assert x4.endswith(os.sep + 'x')
mocksession.report.expect("warning", "*test command found but not*")
-
-def test_sethome_only_on_option(newmocksession, monkeypatch):
- mocksession = newmocksession([], "")
- venv = mocksession.getenv('python')
- action = mocksession.newaction(venv, "qwe", [])
- monkeypatch.setattr(tox.venv, "hack_home_env", None)
- venv._install(["x"], action=action)
-
-
-def test_sethome_works_on_option(newmocksession, monkeypatch):
- mocksession = newmocksession(["--set-home", "-i ALL=http://qwe"], "")
- venv = mocksession.getenv('python')
- action = mocksession.newaction(venv, "qwe", [])
- venv._install(["x"], action=action)
- _, mocked = mocksession.report.getnext("logpopen")
- p = mocked.env["HOME"]
- pydist = py.path.local(p).join(".pydistutils.cfg")
- assert "http://qwe" in pydist.read()
-
-
-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
-
-
-def test_hack_home_env_passthrough(tmpdir, monkeypatch):
- from tox.venv import hack_home_env
- env = hack_home_env(tmpdir, "http://index")
- monkeypatch.setattr(os, "environ", env)
-
- tmpdir = tmpdir.mkdir("tmpdir2")
- env2 = hack_home_env(tmpdir)
- assert env2["HOME"] == str(tmpdir)
- assert env2["PIP_INDEX_URL"] == "http://index"
- assert "index_url = http://index" in \
- tmpdir.join(".pydistutils.cfg").read()
diff --git a/tox/config.py b/tox/config.py
index 9026f28..609208c 100644
--- a/tox/config.py
+++ b/tox/config.py
@@ -283,10 +283,6 @@ def tox_addoption(parser):
parser.add_argument("--develop", action="store_true", dest="develop",
help="install package in the venv using 'setup.py develop' via "
"'pip -e .'")
- parser.add_argument("--set-home", action="store_true", dest="sethome",
- help="(experimental) force creating a new $HOME for each test "
- "environment and create .pydistutils.cfg|pip.conf files "
- "if index servers are specified with tox. ")
parser.add_argument('-i', action="append",
dest="indexurl", metavar="URL",
help="set indexserver url (if URL is of form name=url set the "
@@ -410,10 +406,10 @@ def tox_addoption(parser):
parser.add_testenv_attribute(
name="passenv", type="space-separated-list", postprocess=passenv,
help="environment variables needed during executing test commands "
- "(taken from invocation environment). Not that tox always "
- "passes in some basic environment variables which are needed for "
- "basic functioning of the Python interpreter. See --showconfig "
- "for the resulting passenv setting.")
+ "(taken from invocation environment). Note that tox always "
+ "passes through some basic environment variables which are "
+ "needed for basic functioning of the Python system. "
+ "See --showconfig for the eventual passenv setting.")
parser.add_testenv_attribute(
name="whitelist_externals", type="line-list",
diff --git a/tox/venv.py b/tox/venv.py
index 2f5d583..d3e4e70 100644
--- a/tox/venv.py
+++ b/tox/venv.py
@@ -259,9 +259,7 @@ class VirtualEnv(object):
l.append("--pre")
return l
- def run_install_command(self, packages, options=(),
- indexserver=None, action=None,
- extraenv=None):
+ def run_install_command(self, packages, options=(), action=None):
argv = self.envconfig.install_command[:]
# use pip-script on win32 to avoid the executable locking
i = argv.index('{packages}')
@@ -277,10 +275,7 @@ class VirtualEnv(object):
pass
old_stdout = sys.stdout
sys.stdout = codecs.getwriter('utf8')(sys.stdout)
- if extraenv is None:
- extraenv = {}
- self._pcall(argv, cwd=self.envconfig.config.toxinidir,
- extraenv=extraenv, action=action)
+ self._pcall(argv, cwd=self.envconfig.config.toxinidir, action=action)
sys.stdout = old_stdout
def _install(self, deps, extraopts=None, action=None):
@@ -302,31 +297,26 @@ class VirtualEnv(object):
assert ixserver.url is None or isinstance(ixserver.url, str)
for ixserver in l:
- if self.envconfig.config.option.sethome:
- extraenv = hack_home_env(
- homedir=self.envconfig.envtmpdir.join("pseudo-home"),
- index_url=ixserver.url)
- else:
- extraenv = {}
-
packages = d[ixserver]
options = self._installopts(ixserver.url)
if extraopts:
options.extend(extraopts)
self.run_install_command(packages=packages, options=options,
- action=action, extraenv=extraenv)
+ action=action)
def _getenv(self, extraenv={}):
if extraenv is None:
- # for executing tests
+ # for executing tests we construct a clean environment
env = {}
for envname in self.envconfig.passenv:
if envname in os.environ:
env[envname] = os.environ[envname]
else:
- # for executing install commands
+ # for executing non-test commands we use the full
+ # invocation environment
env = os.environ.copy()
+ # in any case we honor per-testenv setenv configuration
env.update(self.envconfig.setenv)
env['VIRTUAL_ENV'] = str(self.path)
@@ -405,24 +395,3 @@ def getdigest(path):
return "0" * 32
return path.computehash()
-
-def hack_home_env(homedir, index_url=None):
- # 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 not index_url:
- index_url = os.environ.get("TOX_INDEX_URL")
- if index_url:
- homedir.join(".pydistutils.cfg").write(
- "[easy_install]\n"
- "index_url = %s\n" % index_url)
- d["PIP_INDEX_URL"] = index_url
- d["TOX_INDEX_URL"] = index_url
- return d