diff options
author | holger krekel <holger@merlinux.eu> | 2015-05-12 14:01:28 +0200 |
---|---|---|
committer | holger krekel <holger@merlinux.eu> | 2015-05-12 14:01:28 +0200 |
commit | 904844849ae03baab8d37b87267aed27c55e8db0 (patch) | |
tree | 40fffd7df8d2119ecb2b0c8710c65d2724ce63a3 /tox | |
parent | 7549cce84c52115e0b8f47737753698579a6ac0b (diff) | |
download | tox-904844849ae03baab8d37b87267aed27c55e8db0.tar.gz |
- store and show information about what is installed in each venv
- rename internal methods to accomodate the fact that we are not only
installing sdist's
Diffstat (limited to 'tox')
-rw-r--r-- | tox/__init__.py | 2 | ||||
-rw-r--r-- | tox/_cmdline.py | 73 | ||||
-rw-r--r-- | tox/_config.py | 12 | ||||
-rw-r--r-- | tox/_venv.py | 1 | ||||
-rw-r--r-- | tox/result.py | 3 |
5 files changed, 61 insertions, 30 deletions
diff --git a/tox/__init__.py b/tox/__init__.py index e0bff5a..7e71062 100644 --- a/tox/__init__.py +++ b/tox/__init__.py @@ -1,5 +1,5 @@ # -__version__ = '2.0.0.dev2' +__version__ = '2.0.0.dev4' from .hookspecs import hookspec, hookimpl # noqa diff --git a/tox/_cmdline.py b/tox/_cmdline.py index 2a9f391..0c2f9d6 100644 --- a/tox/_cmdline.py +++ b/tox/_cmdline.py @@ -67,10 +67,12 @@ class Action(object): self.venvname = self.venv.name else: self.venvname = "GLOB" - cat = {"runtests": "test", "getenv": "setup"}.get(msg) - if cat: - envlog = session.resultlog.get_envlog(self.venvname) - self.commandlog = envlog.get_commandlog(cat) + if msg == "runtests": + cat = "test" + else: + cat = "setup" + envlog = session.resultlog.get_envlog(self.venvname) + self.commandlog = envlog.get_commandlog(cat) def __enter__(self): self.report.logaction_start(self) @@ -106,7 +108,7 @@ class Action(object): resultjson = self.session.config.option.resultjson if resultjson or redirect: fout = self._initlogpath(self.id) - fout.write("actionid=%s\nmsg=%s\ncmdargs=%r\nenv=%s\n" % ( + fout.write("actionid: %s\nmsg: %s\ncmdargs: %r\nenv: %s\n\n" % ( self.id, self.msg, args, env)) fout.flush() self.popen_outpath = outpath = py.path.local(fout.name) @@ -442,47 +444,47 @@ class Session: venv.status = sys.exc_info()[1] return False - def installpkg(self, venv, sdist_path): - """Install source package in the specified virtual environment. + def installpkg(self, venv, path): + """Install package in the specified virtual environment. :param :class:`tox._config.VenvConfig`: Destination environment - :param str sdist_path: Path to the source distribution. + :param str path: Path to the distribution package. :return: True if package installed otherwise False. :rtype: bool """ - self.resultlog.set_header(installpkg=py.path.local(sdist_path)) - action = self.newaction(venv, "installpkg", sdist_path) + self.resultlog.set_header(installpkg=py.path.local(path)) + action = self.newaction(venv, "installpkg", path) with action: try: - venv.installpkg(sdist_path, action) + venv.installpkg(path, action) return True except tox.exception.InvocationError: venv.status = sys.exc_info()[1] return False - def sdist(self): + def get_installpkg_path(self): """ - :return: Path to the source distribution + :return: Path to the distribution :rtype: py.path.local """ if not self.config.option.sdistonly and (self.config.sdistsrc or self.config.option.installpkg): - sdist_path = self.config.option.installpkg - if not sdist_path: - sdist_path = self.config.sdistsrc - sdist_path = self._resolve_pkg(sdist_path) + path = self.config.option.installpkg + if not path: + path = self.config.sdistsrc + path = self._resolve_pkg(path) self.report.info("using package %r, skipping 'sdist' activity " % - str(sdist_path)) + str(path)) else: try: - sdist_path = self._makesdist() + path = self._makesdist() except tox.exception.InvocationError: v = sys.exc_info()[1] self.report.error("FAIL could not package project - v = %r" % v) return - sdistfile = self.config.distshare.join(sdist_path.basename) - if sdistfile != sdist_path: + sdistfile = self.config.distshare.join(path.basename) + if sdistfile != path: self.report.info("copying new sdistfile to %r" % str(sdistfile)) try: @@ -491,16 +493,16 @@ class Session: self.report.warning("could not copy distfile to %s" % sdistfile.dirpath()) else: - sdist_path.copy(sdistfile) - return sdist_path + path.copy(sdistfile) + return path def subcommand_test(self): if self.config.skipsdist: self.report.info("skipping sdist step") - sdist_path = None + path = None else: - sdist_path = self.sdist() - if not sdist_path: + path = self.get_installpkg_path() + if not path: return 2 if self.config.option.sdistonly: return @@ -514,7 +516,22 @@ class Session: elif self.config.skipsdist or venv.envconfig.skip_install: self.finishvenv(venv) else: - self.installpkg(venv, sdist_path) + self.installpkg(venv, path) + + # write out version dependency information + action = self.newaction(venv, "envreport") + with action: + pip = venv.getcommandpath("pip") + # we can't really call internal helpers here easily :/ + # output = venv._pcall([str(pip), "freeze"], + # cwd=self.config.toxinidir, + # action=action) + output = py.process.cmdexec("%s freeze" % (pip)) + packages = output.strip().split("\n") + action.setactivity("installed", ",".join(packages)) + envlog = self.resultlog.get_envlog(venv.name) + envlog.set_installed(packages) + self.runtestenv(venv) retcode = self._summary() return retcode @@ -589,6 +606,8 @@ class Session: self.report.line(" envdir= %s" % envconfig.envdir) self.report.line(" downloadcache=%s" % envconfig.downloadcache) self.report.line(" usedevelop=%s" % envconfig.usedevelop) + self.report.line(" setenv=%s" % envconfig.setenv) + self.report.line(" passenv=%s" % envconfig.passenv) def showenvs(self): for env in self.config.envlist: diff --git a/tox/_config.py b/tox/_config.py index cbbf5e9..85ff822 100644 --- a/tox/_config.py +++ b/tox/_config.py @@ -21,7 +21,7 @@ iswin32 = sys.platform == "win32" default_factors = {'jython': 'jython', 'pypy': 'pypy', 'pypy3': 'pypy3', 'py': sys.executable} -for version in '24,25,26,27,30,31,32,33,34,35'.split(','): +for version in '26,27,32,33,34,35,36'.split(','): default_factors['py' + version] = 'python%s.%s' % tuple(version) hookimpl = pluggy.HookimplMarker("tox") @@ -361,9 +361,18 @@ def tox_addoption(parser): def passenv(config, reader, section_val): passenv = set(["PATH"]) + + # we ensure that tmp directory settings are passed on + # we could also set it to the per-venv "envtmpdir" + # but this leads to very long paths when run with jenkins + # so we just pass it on by default for now. if sys.platform == "win32": passenv.add("SYSTEMROOT") # needed for python's crypto module passenv.add("PATHEXT") # needed for discovering executables + passenv.add("TEMPDIR") + passenv.add("TMP") + else: + passenv.add("TMPDIR") for spec in section_val: for name in os.environ: if fnmatchcase(name.upper(), spec.upper()): @@ -626,6 +635,7 @@ class parseini: factors=factors) reader.addsubstitutions(**subs) reader.addsubstitutions(envname=name) + reader.vc = vc for env_attr in config._testenv_attr: atype = env_attr.type diff --git a/tox/_venv.py b/tox/_venv.py index d4852bc..d52a6e5 100644 --- a/tox/_venv.py +++ b/tox/_venv.py @@ -327,7 +327,6 @@ class VirtualEnv(object): env['VIRTUAL_ENV'] = str(self.path) env.update(extraenv) - return env def test(self, redirect=False): diff --git a/tox/result.py b/tox/result.py index 7bedd3f..96ac612 100644 --- a/tox/result.py +++ b/tox/result.py @@ -63,6 +63,9 @@ class EnvLog: l = self.dict.setdefault(name, []) return CommandLog(self, l) + def set_installed(self, packages): + self.dict["installed_packages"] = packages + class CommandLog: def __init__(self, envlog, list): |