-
Notifications
You must be signed in to change notification settings - Fork 12
/
setup.py
164 lines (124 loc) · 3.6 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
101
102
103
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
import logging
import re
import subprocess
import sys
from distutils.core import Command
from setuptools import find_packages, setup
with open('bynder_sdk/version.py', 'r', encoding='utf-8') as version_file:
version = re.search(
r'VERSION = [\'"]([^\'"]+)', version_file.read(), re.MULTILINE
).group(1)
with open("README.md", 'r') as readme:
LONG_DESC = readme.read()
log = logging.getLogger(__name__)
log.setLevel(logging.INFO)
def _run_linters():
linters = {
'flake8': ['flake8']
}
if sys.version_info >= (3, 5, 3):
# https://github.com/PyCQA/pylint/issues/1388
linters.update({'pylint': ['pylint', '--output-format', 'parseable']})
for linter_name, command in linters.items():
log.info('Running %s', linter_name)
if subprocess.call(command + ['bynder_sdk', 'test']):
raise SystemExit('{} failed'.format(linter_name))
def _run_type_linting():
if subprocess.call(
['mypy',
'--ignore-missing-imports',
'--follow-imports=skip',
'bynder_sdk']):
raise SystemExit('Type hinting checks failed.')
def _run_tests():
if subprocess.call(
['pytest',
'--cov-report', 'term-missing:skip-covered',
'--cov-report', 'xml',
'--cov', 'bynder_sdk',
'--cov', 'test',
'test']):
raise SystemExit('Linting failed.')
def _run_listdeps():
regex = re.compile('.*bynder.*')
bynder_deps = filter(regex.match, requires)
print(' '.join(bynder_deps))
class PyTest(Command):
user_options = []
def initialize_options(self):
subprocess.call(['pip', 'install'] + requires + test_requires)
def finalize_options(self):
pass
def run(self):
_run_tests()
class Linting(Command):
user_options = []
def initialize_options(self):
subprocess.call(['pip', 'install'] + requires + test_requires)
def finalize_options(self):
pass
def run(self):
_run_linters()
_run_type_linting()
class ListDeps(Command):
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
_run_listdeps()
class TestDeps(Command):
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
print(' '.join(test_requires))
requires = [
'requests>=2.20.0,<=3.0.0',
'requests_oauthlib>=1.1.0,<=2.0.0',
]
test_requires = [
'pylint',
'mypy',
'pytest',
'pytest-cov',
'flake8',
]
commands = {
'test': PyTest,
'lint': Linting,
'listdeps': ListDeps,
'testdeps': TestDeps,
}
setup(
name='bynder-sdk',
version=version,
description=(
'Bynder SDK can be used to speed up the'
' integration of Bynder in Python'
),
long_description=LONG_DESC,
long_description_content_type='text/markdown',
url='https://bynder.com',
author='Bynder',
author_email='[email protected]',
license='MIT',
cmdclass=commands,
packages=find_packages(),
install_requires=requires,
tests_require=test_requires,
include_package_data=True,
keywords='bynder, dam',
classifiers=[
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Operating System :: OS Independent',
'Topic :: Software Development :: Libraries :: Python Modules',
],
zip_safe=False
)