-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
73 lines (63 loc) · 1.83 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import os
import shutil
import subprocess
import sys
from setuptools import (
Command,
setup,
)
sys.path.insert(0, "src")
from socket_burst_dampener import (
__author__,
__description__,
__email__,
__project__,
__version__,
)
sys.path.remove("src")
class PyTest(Command):
user_options = [
("match=", "k", "Run only tests that match the provided expressions")
]
def initialize_options(self):
self.match = None
def finalize_options(self):
pass
def run(self):
testpath = "./test"
os.environ["EPYTHON"] = "python{}.{}".format(
sys.version_info.major, sys.version_info.minor
)
pythonpath = list(filter(None, os.environ.get("PYTHONPATH", "").split(":")))
pythonpath.insert(0, os.path.join(os.path.abspath(os.path.dirname(testpath)), "src"))
os.environ["PYTHONPATH"] = ":".join(pythonpath)
pytest_exe = shutil.which("py.test")
if pytest_exe is not None:
test_cmd = (
[
pytest_exe,
"-v",
testpath,
"--cov-report=xml",
"--cov-report=term-missing",
]
+ (["-k", self.match] if self.match else [])
+ ["--cov=socket_burst_dampener"]
)
else:
test_cmd = ["python", "test/test_socket_burst_dampener.py"]
subprocess.check_call(test_cmd)
setup(
name=__project__,
version=__version__,
description=__description__,
author=__author__,
author_email=__email__,
cmdclass={'test': PyTest},
package_dir={'': 'src'},
py_modules=['socket_burst_dampener'],
entry_points={
'console_scripts': 'socket-burst-dampener = socket_burst_dampener:main',
},
python_requires = ">=3.6",
)