setup.py 5.1 KB
Newer Older
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
# 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
import pathlib
from typing import List, Tuple

from setuptools import setup, find_packages, Command

import superbench

here = pathlib.Path(__file__).parent.resolve()
long_description = (here / 'README.md').read_text(encoding='utf-8')


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: List[Tuple[str, str, str]] = []

    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."""
44
45
        errno = os.system('python3 -m yapf --in-place --recursive --exclude .git .')
        sys.exit(0 if errno == 0 else 1)
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68


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 flake8'
    user_options: List[Tuple[str, str, str]] = []

    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."""
69
70
71
72
73
74
75
76
77
78
        errno = os.system(
            ' && '.join(
                [
                    'python3 -m yapf --diff --recursive --exclude .git .',
                    'python3 -m mypy .',
                    'python3 -m flake8',
                ]
            )
        )
        sys.exit(0 if errno == 0 else 1)
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101


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: List[Tuple[str, str, str]] = []

    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."""
102
        errno = os.system('python3 -m pytest -v --cov=superbench --cov-report=xml --cov-report=term-missing tests/')
103
        sys.exit(0 if errno == 0 else 1)
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134


setup(
    name='superbench',
    version=superbench.__version__,
    description='Provide hardware and software benchmarks for AI systems.',
    long_description=long_description,
    long_description_content_type='text/markdown',
    url='https://github.com/microsoft/superbenchmark',
    author=superbench.__author__,
    author_email='superbench@microsoft.com',
    license='MIT',
    classifiers=[
        'Development Status :: 2 - Pre-Alpha',
        'Environment :: GPU',
        'Intended Audience :: System Administrators',
        'License :: OSI Approved :: MIT License',
        'Operating System :: POSIX',
        'Programming Language :: Python :: 3',
        'Programming Language :: Python :: 3 :: Only',
        'Programming Language :: Python :: 3.6',
        'Programming Language :: Python :: 3.7',
        'Programming Language :: Python :: 3.8',
        'Programming Language :: Python :: 3.9',
        'Topic :: System :: Benchmark',
        'Topic :: System :: Clustering',
        'Topic :: System :: Hardware',
    ],
    keywords='benchmark, AI systems',
    packages=find_packages(exclude=['tests']),
    python_requires='>=3.6, <4',
135
    install_requires=[
136
137
        'ansible_base>=2.10.9;os_name=="posix"',
        'ansible_runner>=1.4.7',
Yifan Xiong's avatar
Yifan Xiong committed
138
        'colorlog>=4.7.2',
139
        'joblib>=1.0.1',
140
        'knack>=0.7.2',
141
        'omegaconf==2.0.6',
142
    ],
143
    extras_require={
Yifan Xiong's avatar
Yifan Xiong committed
144
        'dev': ['pre-commit>=2.10.0'],
145
        'test': [
Yifan Xiong's avatar
Yifan Xiong committed
146
            'flake8-docstrings>=1.5.0',
147
148
149
            'flake8-quotes>=3.2.0',
            'flake8>=3.8.4',
            'mypy>=0.800',
Yifan Xiong's avatar
Yifan Xiong committed
150
            'pydocstyle>=5.1.1',
151
            'pytest-cov>=2.11.1',
Yifan Xiong's avatar
Yifan Xiong committed
152
            'pytest-subtests>=0.4.0',
153
            'pytest>=6.2.2',
154
            'types-pyyaml',
155
156
            'vcrpy>=4.1.1',
            'yapf>=0.30.0',
157
        ],
158
        'torch': [
159
160
161
            'torch>=1.7.0',
            'torchvision>=0.8.0',
            'transformers>=4.3.3',
162
        ],
163
        'nvidia': ['py3nvml>=0.2.6']
164
    },
165
    include_package_data=True,
166
    entry_points={
167
168
169
        'console_scripts': [
            'sb = superbench.cli.sb:main',
        ],
170
171
172
173
174
175
    },
    cmdclass={
        'format': Formatter,
        'lint': Linter,
        'test': Tester,
    },
Yifan Xiong's avatar
Yifan Xiong committed
176
177
178
179
    project_urls={
        'Source': 'https://github.com/microsoft/superbenchmark',
        'Tracker': 'https://github.com/microsoft/superbenchmark/issues',
    },
180
)