forked from python-bugzilla/python-bugzilla
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
executable file
·143 lines (113 loc) · 3.89 KB
/
setup.py
File metadata and controls
executable file
·143 lines (113 loc) · 3.89 KB
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
#!/usr/bin/env python3
from __future__ import print_function
import glob
import os
import sys
from distutils.core import Command
from setuptools import setup
def unsupported_python_version():
return sys.version_info < (2, 7) \
or (sys.version_info > (3,) and sys.version_info < (3, 4))
if unsupported_python_version():
raise ImportError("python-bugzilla does not support this python version")
def get_version():
f = open("bugzilla/apiversion.py")
for line in f:
if line.startswith('version = '):
return eval(line.split('=')[-1]) # pylint: disable=eval-used
class TestCommand(Command):
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
print("\n* Tests are now run with the 'pytest' tool.\n"
"* See CONTRIBUTING.md for details.")
class PylintCommand(Command):
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
import pylint.lint
import pycodestyle
files = (["bugzilla-cli", "bugzilla", "setup.py"] +
glob.glob("examples/*.py") +
glob.glob("tests/*.py"))
output_format = sys.stdout.isatty() and "colorized" or "text"
print("running pycodestyle")
style_guide = pycodestyle.StyleGuide(
config_file='tox.ini',
format="pylint",
paths=files,
)
report = style_guide.check_files()
if style_guide.options.count:
sys.stderr.write(str(report.total_errors) + '\n')
print("running pylint")
pylint_opts = [
"--rcfile", "pylintrc",
"--output-format=%s" % output_format,
]
pylint.lint.Run(files + pylint_opts)
class RPMCommand(Command):
description = "Build src and binary rpms."
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
"""
Run sdist, then 'rpmbuild' the tar.gz
"""
os.system("cp python-bugzilla.spec /tmp")
try:
os.system("rm -rf python-bugzilla-%s" % get_version())
self.run_command('sdist')
os.system('rpmbuild -ta --clean dist/python-bugzilla-%s.tar.gz' %
get_version())
finally:
os.system("mv /tmp/python-bugzilla.spec .")
def _parse_requirements(fname):
ret = []
for line in open(fname).readlines():
if not line or line.startswith("#"):
continue
ret.append(line)
return ret
setup(
name='python-bugzilla',
version=get_version(),
description='Bugzilla XMLRPC access module',
author='Cole Robinson',
license="GPLv2",
url='https://github.com/python-bugzilla/python-bugzilla',
classifiers=[
'Topic :: Software Development :: Libraries :: Python Modules',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
],
packages=['bugzilla'],
entry_points={'console_scripts': ['bugzilla = bugzilla._cli:cli']},
data_files=[('share/man/man1', ['bugzilla.1'])],
install_requires=_parse_requirements("requirements.txt"),
tests_require=_parse_requirements("test-requirements.txt"),
cmdclass={
"pylint": PylintCommand,
"rpm": RPMCommand,
"test": TestCommand,
},
)