setup.py 7.12 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 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

15
import pkg_resources
16
17
18
19
from setuptools import setup, find_packages, Command

import superbench

20
try:
21
    pkg_resources.require(['pip>=18', 'setuptools>=45, <66'])
22
except (pkg_resources.VersionConflict, pkg_resources.DistributionNotFound):
23
24
25
26
    print(
        '\033[93mTry update pip/setuptools versions, for example, '
        'python3 -m pip install --upgrade pip wheel setuptools==65.7\033[0m'
    )
27
28
    raise

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
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."""
54
        errno = os.system('python3 -m yapf --in-place --recursive --exclude .git --exclude .eggs .')
55
        sys.exit(0 if errno == 0 else 1)
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78


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."""
79
80
81
        errno = os.system(
            ' && '.join(
                [
82
                    'python3 -m yapf --diff --recursive --exclude .git --exclude .eggs .',
83
84
85
86
87
88
                    'python3 -m mypy .',
                    'python3 -m flake8',
                ]
            )
        )
        sys.exit(0 if errno == 0 else 1)
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111


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."""
112
        errno = os.system('python3 -m pytest -v --cov=superbench --cov-report=xml --cov-report=term-missing tests/')
113
        sys.exit(0 if errno == 0 else 1)
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144


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',
145
146
147
148
149
150
151
152
    use_scm_version={
        'local_scheme': 'node-and-date',
        'version_scheme': lambda _: superbench.__version__,
        'fallback_version': f'{superbench.__version__}+unknown',
    },
    setup_requires=[
        'setuptools_scm',
    ],
153
    install_requires=[
154
        'ansible_base>=2.10.9;os_name=="posix"',
155
        'ansible_runner>=2.0.0rc1, <2.3.2',
156
        'colorlog>=6.7.0',
157
        'importlib_metadata',
158
        'jinja2>=2.10.1',
159
        'joblib>=1.0.1',
160
        'jsonlines>=2.0.0',
161
        'knack>=0.7.2',
162
        'markdown>=3.3.0',
163
        'matplotlib>=3.0.0',
164
        'natsort>=7.1.1',
165
        'networkx>=2.5',
166
        'numpy>=1.19.2',
167
        'omegaconf==2.3.0',
168
        'openpyxl>=3.0.7',
169
        'packaging>=21.0',
170
        'pandas>=1.1.5',
171
        'protobuf<=3.20.3',
172
        'pssh @ git+https://github.com/lilydjwg/pssh.git@v2.3.4',
173
        'pyyaml>=5.3',
174
        'requests>=2.27.1',
175
        'seaborn>=0.11.2',
176
        'tcping>=0.1.1rc1',
177
        'urllib3>=1.26.9',
178
179
        'xlrd>=2.0.1',
        'xlsxwriter>=1.3.8',
180
        'xmltodict>=0.12.0',
181
        'types-requests',
182
    ],
183
184
185
186
187
    extras_require=(
        lambda x: {
            **x,
            'develop': x['dev'] + x['test'],
            'cpuworker': x['torch'],
188
            'amdworker': x['torch'] + x['amd'],
189
            'nvworker': x['torch'] + x['ort'] + x['nvidia'],
190
191
192
193
194
195
196
        }
    )(
        {
            'dev': ['pre-commit>=2.10.0'],
            'test': [
                'flake8-docstrings>=1.5.0',
                'flake8-quotes>=3.2.0',
197
                'flake8>=3.8.4, <6.0.0',
198
199
200
201
                'mypy>=0.800',
                'pydocstyle>=5.1.1',
                'pytest-cov>=2.11.1',
                'pytest-subtests>=0.4.0',
202
                'pytest>=6.2.2, <=7.4.4',
203
                'types-markdown',
204
                'types-setuptools',
205
                'types-pyyaml',
206
                'typing-extensions>=3.10',
207
                'urllib3<2.0',
208
209
210
211
212
213
                'vcrpy>=4.1.1',
                'yapf==0.31.0',
            ],
            'torch': [
                'torch>=1.7.0a0',
                'torchvision>=0.8.0a0',
214
                'transformers>=4.3.3, <4.23.0',
215
216
217
            ],
            'ort': [
                'onnx>=1.10.2',
218
                'onnxruntime-gpu==1.12.0; python_version<"3.10" and platform_machine == "x86_64"',
219
                'onnxruntime-gpu; python_version>="3.10" and platform_machine == "x86_64"',
220
221
            ],
            'nvidia': ['py3nvml>=0.2.6'],
222
            'amd': ['amdsmi'],
223
224
        }
    ),
225
    include_package_data=True,
226
    entry_points={
227
228
229
        'console_scripts': [
            'sb = superbench.cli.sb:main',
        ],
230
231
232
233
234
235
    },
    cmdclass={
        'format': Formatter,
        'lint': Linter,
        'test': Tester,
    },
Yifan Xiong's avatar
Yifan Xiong committed
236
237
238
239
    project_urls={
        'Source': 'https://github.com/microsoft/superbenchmark',
        'Tracker': 'https://github.com/microsoft/superbenchmark/issues',
    },
240
)