-
Notifications
You must be signed in to change notification settings - Fork 82
/
setup.py
105 lines (82 loc) · 2.83 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
# -*- coding: utf-8 -
import os
import sys
from setuptools import setup
from setuptools.command.test import test as TestCommand
from gunicorn_thrift import __version__
CLASSIFIERS = [
'Development Status :: 3 - Alpha',
'Environment :: Other Environment',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: MacOS :: MacOS X',
'Operating System :: POSIX',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Topic :: Utilities',
'Topic :: Software Development :: Libraries :: Python Modules',
]
PY_VERSION = sys.version_info[:3]
# read dev requirements
if PY_VERSION < (2, 7, 0):
raise RuntimeError('Python < 2.7 is unsupported')
elif PY_VERSION >= (3, 0, 0) and PY_VERSION < (3, 4, 0):
raise RuntimeError('Python 3 < 3.4 is unsupported')
if PY_VERSION[0] == 2:
fname = os.path.join(os.path.dirname(__file__), 'requirements_py27.txt')
else:
fname = os.path.join(os.path.dirname(__file__), 'requirements_py3x.txt')
with open(fname) as f:
REQUIREMENTS = list(map(lambda l: l.strip(), f.readlines()))
# read dev requirements
if PY_VERSION[0] < 3:
fname = os.path.join(os.path.dirname(__file__),
'test_requirements_py27.txt')
else:
fname = os.path.join(os.path.dirname(__file__),
'test_requirements_py3x.txt')
with open(fname) as f:
TEST_REQUIREMENTS = list(map(lambda l: l.strip(), f.readlines()))
class PyTest(TestCommand):
def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = [
'tests', '--cov', 'gunicorn_thrift', '--cov-report',
'term-missing', '--cov-config', '.coveragerc',
]
self.test_suite = True
def run_tests(self):
import pytest
errno = pytest.main(self.test_args)
sys.exit(errno)
py_modules = []
for root, folders, files in os.walk('gunicorn_thrift'):
for f in files:
if f.endswith('.py'):
full = os.path.join(root, f[:-3])
parts = full.split(os.path.sep)
modname = '.'.join(parts)
py_modules.append(modname)
setup(
name='gunicorn_thrift',
version=__version__,
description='Thrift server using gunicorn',
author='Haochuan Guo',
author_email='[email protected]',
license='MIT',
classifiers=CLASSIFIERS,
zip_safe=False,
py_modules=py_modules,
include_package_data=True,
tests_require=TEST_REQUIREMENTS,
cmdclass={'test': PyTest},
install_requires=REQUIREMENTS,
entry_points="""
[console_scripts]
gunicorn_thrift=gunicorn_thrift.thriftapp:run
"""
)