summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorBenjamin Schubert <bschubert15@bloomberg.net>2018-10-19 17:39:49 +0100
committerBenjamin Schubert <ben.c.schubert@gmail.com>2018-11-01 10:49:57 +0000
commitb27b592a64a7050a205fa17c807fac193990b2a7 (patch)
treef4ad3d47c4ae36043cde39a0ae56862ab3930810 /setup.py
parentb8a37a63764320d8e84f89089935026dec0af63b (diff)
downloadbuildstream-b27b592a64a7050a205fa17c807fac193990b2a7.tar.gz
Remove dependency on pytest-runner
This includes a new command mimicking pytest-runner so that we can drop this dependency This was the only setup_requires dependency that we had and will make like easier for people behind proxies
Diffstat (limited to 'setup.py')
-rwxr-xr-xsetup.py41
1 files changed, 40 insertions, 1 deletions
diff --git a/setup.py b/setup.py
index 2f7247aeb..76610f0ef 100755
--- a/setup.py
+++ b/setup.py
@@ -39,6 +39,7 @@ if sys.version_info[0] != REQUIRED_PYTHON_MAJOR or sys.version_info[1] < REQUIRE
try:
from setuptools import setup, find_packages, Command
from setuptools.command.easy_install import ScriptWriter
+ from setuptools.command.test import test as TestCommand
except ImportError:
print("BuildStream requires setuptools in order to build. Install it using"
" your package manager (usually python3-setuptools) or via pip (pip3"
@@ -219,9 +220,48 @@ class BuildGRPC(Command):
f.write(code)
+#####################################################
+# Pytest command #
+#####################################################
+class PyTest(TestCommand):
+ """Defines a pytest command class to run tests from setup.py"""
+
+ user_options = TestCommand.user_options + [
+ ("addopts=", None, "Arguments to pass to pytest"),
+ ('index-url=', None, "Specify an index url from which to retrieve "
+ "dependencies"),
+ ]
+
+ # pylint: disable=attribute-defined-outside-init
+ def initialize_options(self):
+ super().initialize_options()
+ self.addopts = ""
+ self.index_url = None
+
+ def run(self):
+ if self.index_url is not None:
+ if self.distribution.command_options.get("easy_install") is None:
+ self.distribution.command_options["easy_install"] = {}
+
+ self.distribution.command_options["easy_install"]["index_url"] = (
+ "cmdline", self.index_url,
+ )
+ super().run()
+
+ def run_tests(self):
+ import shlex
+ import pytest
+
+ errno = pytest.main(shlex.split(self.addopts))
+
+ if errno:
+ raise SystemExit(errno)
+
+
def get_cmdclass():
cmdclass = {
'build_grpc': BuildGRPC,
+ 'pytest': PyTest,
}
cmdclass.update(versioneer.get_cmdclass())
return cmdclass
@@ -305,6 +345,5 @@ setup(name='BuildStream',
'grpcio >= 1.10',
],
entry_points=bst_install_entry_points,
- setup_requires=['pytest-runner'],
tests_require=dev_requires,
zip_safe=False)