forked from bobuss/pynba
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsetup.py
130 lines (113 loc) · 4.12 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
import os
import platform
from setuptools import setup, find_packages, Extension, Command
import sys
here = os.path.abspath(os.path.dirname(__file__))
README = open(os.path.join(here, 'README.rst')).read()
NEWS = open(os.path.join(here, 'NEWS.txt')).read()
version = '0.5.5'
install_requires = [
'six'
]
def loop(directory, module=None):
for file in os.listdir(directory):
path = os.path.join(directory, file)
name = module + "." + file if module else file
if os.path.isfile(path):
yield path, name.rpartition('.')[0]
elif os.path.isdir(path):
for path2, name2 in loop(path, name):
yield path2, name2
# make extensions
def extension_maker():
extensions = []
if platform.python_implementation() == 'CPython':
for path, name in loop('pynba', 'pynba'):
if path.endswith(".c"):
extensions.append(
Extension(
name=name,
sources=[path]
)
)
return extensions
class CythonizeCommand(Command):
description = "cythonize all *.pyx files"
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
from distutils.spawn import find_executable
import subprocess
import sys
exitcode = 0
errno = 0
executable = find_executable('cython')
if not executable:
print('cython is not installed')
exitcode = 1
else:
for path, name in loop('pynba', 'pynba'):
if path.endswith(".pyx"):
dest = path.rpartition('.')[0] + '.c'
if os.path.exists(dest) and os.path.getmtime(path) <= os.path.getmtime(dest):
print('cythonize {} noop'.format(path))
continue
else:
errno = subprocess.call([executable, path])
print('cythonize {} ok'.format(path))
if errno != 0:
exitcode = errno
print('cythonize {} failed'.format(path))
if exitcode > 0:
raise SystemExit(exitcode)
setup(
name='pynba',
version=version,
description=str(
'lightweight timers and wsgi middleware to '
'monitor performance in production systems'
),
long_description=README + '\n\n' + NEWS,
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Intended Audience :: Information Technology",
"Intended Audience :: System Administrators",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Internet :: Log Analysis",
"Topic :: Internet :: WWW/HTTP :: Dynamic Content :: Page Counters",
"Topic :: Internet :: WWW/HTTP :: WSGI :: Middleware",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: System :: Monitoring",
"Topic :: Utilities"
],
packages=find_packages(),
keywords='pinba wsgi monitoring',
author='Xavier Barbosa',
author_email='[email protected]',
url='https://github.com/johnnoone/pynba',
license='MIT',
include_package_data=True,
zip_safe=False,
install_requires=install_requires,
# see https://www.python.org/dev/peps/pep-0426/#environment-markers
extras_require={
':python_version=="2.7"': ['enum34'],
':python_version=="3.2"': ['enum34'],
':python_version=="3.3"': ['enum34'],
},
tests_require=[],
ext_modules=extension_maker(),
cmdclass = {'cythonize': CythonizeCommand},
)