From 2e31dd2ad3bdb67a2b66ad1227110c1c29a1add6 Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Mon, 24 Aug 2015 17:17:31 +0100 Subject: Add tox.ini file for synapse --- setup.py | 5 ----- 1 file changed, 5 deletions(-) (limited to 'setup.py') diff --git a/setup.py b/setup.py index 16ccc0f1b8..8ad20df7cb 100755 --- a/setup.py +++ b/setup.py @@ -47,11 +47,6 @@ setup( packages=find_packages(exclude=["tests", "tests.*"]), description="Reference Synapse Home Server", install_requires=dependencies['requirements'](include_conditional=True).keys(), - setup_requires=[ - "Twisted>=15.1.0", # Here to override setuptools_trial's dependency on Twisted>=2.4.0 - "setuptools_trial", - "mock" - ], dependency_links=dependencies["DEPENDENCY_LINKS"], include_package_data=True, zip_safe=False, -- cgit 1.4.1 From 4f6fa981ec9035b2708ba0dc9db21d5dd629f389 Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Wed, 26 Aug 2015 12:45:29 +0100 Subject: Make 'setup.py test' run tox --- setup.cfg | 3 --- setup.py | 27 ++++++++++++++++++++++++++- tox.ini | 2 +- 3 files changed, 27 insertions(+), 5 deletions(-) (limited to 'setup.py') diff --git a/setup.cfg b/setup.cfg index abb649958e..ba027c7d13 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,9 +3,6 @@ source-dir = docs/sphinx build-dir = docs/build all_files = 1 -[aliases] -test = trial - [trial] test_suite = tests diff --git a/setup.py b/setup.py index 8ad20df7cb..adc3316928 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,28 @@ 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 + import tox + import shlex + args = self.tox_args + if args: + args = shlex.split(self.tox_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 +75,6 @@ setup( zip_safe=False, long_description=long_description, scripts=["synctl"] + glob.glob("scripts/*"), + tests_require=['tox'], + cmdclass={'test': Tox}, ) diff --git a/tox.ini b/tox.ini index 370a63cbb8..3f0649b628 100644 --- a/tox.ini +++ b/tox.ini @@ -9,7 +9,7 @@ deps = setenv = PYTHONDONTWRITEBYTECODE = no_byte_code commands = - coverage run --source=./synapse {envbindir}/trial {posargs:tests} + coverage run --source=synapse {envbindir}/trial {posargs:tests} coverage report -m install_command = pip install --process-dependency-links --pre {opts} {packages} -- cgit 1.4.1 From fd246fde8934f1461589df20efcf53ae1bd0e90d Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Wed, 26 Aug 2015 12:59:02 +0100 Subject: Install tox locally if it wasn't already installed when running setup.py test --- setup.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'setup.py') diff --git a/setup.py b/setup.py index adc3316928..4a7b3c99aa 100755 --- a/setup.py +++ b/setup.py @@ -51,7 +51,16 @@ class Tox(Command): def run(self): #import here, cause outside the eggs aren't loaded - import tox + 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: @@ -75,6 +84,5 @@ setup( zip_safe=False, long_description=long_description, scripts=["synctl"] + glob.glob("scripts/*"), - tests_require=['tox'], cmdclass={'test': Tox}, ) -- cgit 1.4.1 From 06094591c5397af64a495dce2271da2df5b491b9 Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Wed, 26 Aug 2015 13:13:01 +0100 Subject: Pass an empty list of arguments to tox if no arguments are given --- setup.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'setup.py') diff --git a/setup.py b/setup.py index 4a7b3c99aa..0e3f2f18d5 100755 --- a/setup.py +++ b/setup.py @@ -65,6 +65,8 @@ class Tox(Command): args = self.tox_args if args: args = shlex.split(self.tox_args) + else: + args = [] errno = tox.cmdline(args=args) sys.exit(errno) -- cgit 1.4.1