summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty Taylor <mordred@inaugust.com>2013-07-10 17:41:45 -0400
committerMonty Taylor <mordred@inaugust.com>2013-07-10 17:41:45 -0400
commit33b85d4875732250490f24a9cde83210dcba83d8 (patch)
tree9d6936fe60a58d45a2dc3d16588c02a00b9996c7
parent1305a6c913cc3f86978c966ed36c3e48f61d70ec (diff)
downloadtox-33b85d4875732250490f24a9cde83210dcba83d8.tar.gz
Add support for installing via setup.py develop.
-rw-r--r--doc/config.txt1
-rw-r--r--tox/_cmdline.py19
-rw-r--r--tox/_config.py4
-rw-r--r--tox/_venv.py24
4 files changed, 44 insertions, 4 deletions
diff --git a/doc/config.txt b/doc/config.txt
index 9a72abf..356530a 100644
--- a/doc/config.txt
+++ b/doc/config.txt
@@ -22,6 +22,7 @@ List of optional global options::
distshare=path # defaults to {homedir}/.tox/distshare
envlist=ENVLIST # defaults to the list of all environments
skipsdist=BOOL # defaults to false
+ usedevelop=BOOL # use python setup.py develop, defaults to false
``tox`` autodetects if it is running in a Jenkins_ context
diff --git a/tox/_cmdline.py b/tox/_cmdline.py
index 02cdf09..e28c04b 100644
--- a/tox/_cmdline.py
+++ b/tox/_cmdline.py
@@ -333,6 +333,16 @@ class Session:
venv.finish()
return True
+ def developpkg(self, venv, setupdir):
+ action = self.newaction(venv, "developpkg", setupdir)
+ with action:
+ try:
+ venv.developpkg(setupdir, action)
+ return True
+ except tox.exception.InvocationError:
+ venv.status = sys.exc_info()[1]
+ return False
+
def installpkg(self, venv, sdist_path):
action = self.newaction(venv, "installpkg", sdist_path)
with action:
@@ -379,10 +389,12 @@ class Session:
return
for venv in self.venvlist:
if self.setupenv(venv):
- if not self.config.skipsdist:
- self.installpkg(venv, sdist_path)
- else:
+ if self.config.skipsdist:
+ if self.config.usedevelop:
+ self.developpkg(venv, self.config.setupdir)
self.finishvenv(venv)
+ else:
+ self.installpkg(venv, sdist_path)
self.runtestenv(venv)
retcode = self._summary()
return retcode
@@ -422,6 +434,7 @@ class Session:
self.report.keyvalue("setupdir: ", self.config.setupdir)
self.report.keyvalue("distshare: ", self.config.distshare)
self.report.keyvalue("skipsdist: ", self.config.skipsdist)
+ self.report.keyvalue("usedevelop: ", self.config.usedevelop)
self.report.tw.line()
for envconfig in self.config.envconfigs.values():
self.report.line("[testenv:%s]" % envconfig.envname, bold=True)
diff --git a/tox/_config.py b/tox/_config.py
index 96eb4c1..d6e39e4 100644
--- a/tox/_config.py
+++ b/tox/_config.py
@@ -194,7 +194,9 @@ class parseini:
homedir=config.homedir)
config.toxworkdir = reader.getpath(toxsection, "toxworkdir",
"{toxinidir}/.tox")
- config.skipsdist = reader.getbool(toxsection, "skipsdist", False)
+ config.usedevelop = reader.getbool(toxsection, "usedevelop", False)
+ config.skipsdist = reader.getbool(
+ toxsection, "skipsdist", config.usedevelop)
config.minversion = reader.getdefault(toxsection, "minversion", None)
# determine indexserver dictionary
diff --git a/tox/_venv.py b/tox/_venv.py
index 9b62f02..f604f10 100644
--- a/tox/_venv.py
+++ b/tox/_venv.py
@@ -1,4 +1,5 @@
from __future__ import with_statement
+import subprocess
import sys, os, re
import py
import tox
@@ -200,6 +201,29 @@ class VirtualEnv(object):
def finish(self):
self._getliveconfig().writeconfig(self.path_config)
+ def _needs_reinstall(self, setupdir, action):
+ setup_py = setupdir.join('setup.py')
+ setup_cfg = setupdir.join('setup.cfg')
+ args = [str(self.getconfigexecutable()), str(setup_py), '--name']
+ output = subprocess.Popen(args, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ out = output.communicate()
+ name = out[0].strip().decode('utf-8')
+ egg_info = setupdir.join('.'.join((name, 'egg-info')))
+ for conf_file in (setup_py, setup_cfg):
+ if (conf_file.check()
+ and conf_file.mtime() > egg_info.mtime()):
+ return True
+ return False
+
+ def developpkg(self, setupdir, action):
+ assert action is not None
+ self.finish()
+ if not self._needs_reinstall(setupdir, action):
+ return
+ extraopts = ['--no-deps']
+ self._install(['-e', setupdir], extraopts=extraopts, action=action)
+
def installpkg(self, sdistpath, action):
assert action is not None
if getattr(self, 'just_created', False):