-
Notifications
You must be signed in to change notification settings - Fork 44
/
setup.py
100 lines (73 loc) · 2.53 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
"""The setuptools based setup module.
Reference:
https://packaging.python.org/guides/distributing-packages-using-setuptools/
"""
import os
import sys
from setuptools import setup, Command
class Formatter(Command):
"""Cmdclass for `python setup.py format`.
Args:
Command (distutils.cmd.Command):
Abstract base class for defining command classes.
"""
description = 'format the code using yapf'
user_options = []
def initialize_options(self):
"""Set default values for options that this command supports."""
pass
def finalize_options(self):
"""Set final values for options that this command supports."""
pass
def run(self):
"""Fromat the code using yapf."""
errno = os.system('python3 -m yapf --in-place --recursive --exclude .git --exclude .eggs .')
sys.exit(0 if errno == 0 else 1)
class Linter(Command):
"""Cmdclass for `python setup.py lint`.
Args:
Command (distutils.cmd.Command):
Abstract base class for defining command classes.
"""
description = 'lint the code using yapf and flake8'
user_options = []
def initialize_options(self):
"""Set default values for options that this command supports."""
pass
def finalize_options(self):
"""Set final values for options that this command supports."""
pass
def run(self):
"""Lint the code with yapf, mypy, and flake8."""
errno = os.system(
' && '.join([
'python3 -m yapf --diff --recursive --exclude .git --exclude .eggs .',
'python3 -m flake8',
])
)
sys.exit(0 if errno == 0 else 1)
class Tester(Command):
"""Cmdclass for `python setup.py test`.
Args:
Command (distutils.cmd.Command):
Abstract base class for defining command classes.
"""
description = 'test the code using pytest'
user_options = []
def initialize_options(self):
"""Set default values for options that this command supports."""
pass
def finalize_options(self):
"""Set final values for options that this command supports."""
pass
def run(self):
"""Run pytest."""
errno = os.system('python3 -m pytest -v --cov=msamp --cov-report=xml --cov-report=term-missing tests/')
sys.exit(0 if errno == 0 else 1)
setup(cmdclass={
'format': Formatter,
'lint': Linter,
'test': Tester,
})