forked from Bynder/bynder-python-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
136 lines (103 loc) · 3.03 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
import logging
import subprocess
import re
from distutils.core import Command
from setuptools import setup, find_packages
with open("VERSION") as fh:
__version__ = fh.read().strip()
with open("README.rst", 'r') as readme:
LONG_DESC = readme.read()
build_version = __version__
log = logging.getLogger(__name__)
log.setLevel(logging.INFO)
def _run_linters():
linters = {
'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():
import pytest
errno = pytest.main(['--cov-report', 'term-missing:skip-covered',
'--cov-report', 'xml',
'--cov', 'bynder_sdk',
'--cov', 'test',
'test'])
raise SystemExit(errno)
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'] + test_requires)
def finalize_options(self):
pass
def run(self):
_run_linters()
_run_type_linting()
_run_tests()
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.18.4',
'requests_oauthlib==0.8.0',
]
test_requires = [
'pylint==1.7.0',
'mypy==0.501',
'pytest',
'pytest-cov',
]
setup(
name='bynder-sdk',
version=build_version,
description=(
'Bynder SDK can be used to speed up the'
' integration of Bynder in Python'
),
long_description=LONG_DESC,
url='https://bynder.com',
author='Bynder',
author_email='[email protected]',
license='MIT',
cmdclass={'test': PyTest, 'listdeps': ListDeps, 'testdeps': TestDeps},
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
)