diff options
author | Mark Haines <mjark@negativecurvature.net> | 2015-08-26 13:50:59 +0100 |
---|---|---|
committer | Mark Haines <mjark@negativecurvature.net> | 2015-08-26 13:50:59 +0100 |
commit | 4c56928263efa3b5ce5b2eba79172872e8a27990 (patch) | |
tree | e19e47f5744a2a4620c78d9d83eb0a4a8803695a /setup.py | |
parent | Merge pull request #255 from matrix-org/mergeeriksmadness (diff) | |
parent | Pass an empty list of arguments to tox if no arguments are given (diff) | |
download | synapse-4c56928263efa3b5ce5b2eba79172872e8a27990.tar.xz |
Merge pull request #254 from matrix-org/markjh/tox_setuptools
Make 'setup.py test' run tox
Diffstat (limited to 'setup.py')
-rwxr-xr-x | setup.py | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/setup.py b/setup.py index 8ad20df7cb..0e3f2f18d5 100755 --- a/setup.py +++ b/setup.py @@ -16,7 +16,8 @@ import glob import os -from setuptools import setup, find_packages +from setuptools import setup, find_packages, Command +import sys here = os.path.abspath(os.path.dirname(__file__)) @@ -37,6 +38,39 @@ def exec_file(path_segments): exec(code, result) return result + +class Tox(Command): + user_options = [('tox-args=', 'a', "Arguments to pass to tox")] + + def initialize_options(self): + self.tox_args = None + + def finalize_options(self): + self.test_args = [] + self.test_suite = True + + def run(self): + #import here, cause outside the eggs aren't loaded + try: + import tox + except ImportError: + try: + self.distribution.fetch_build_eggs("tox") + import tox + except: + raise RuntimeError( + "The tests need 'tox' to run. Please install 'tox'." + ) + import shlex + args = self.tox_args + if args: + args = shlex.split(self.tox_args) + else: + args = [] + errno = tox.cmdline(args=args) + sys.exit(errno) + + version = exec_file(("synapse", "__init__.py"))["__version__"] dependencies = exec_file(("synapse", "python_dependencies.py")) long_description = read_file(("README.rst",)) @@ -52,4 +86,5 @@ setup( zip_safe=False, long_description=long_description, scripts=["synctl"] + glob.glob("scripts/*"), + cmdclass={'test': Tox}, ) |