forked from vmprof/vmprof-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
122 lines (115 loc) · 4.2 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
from setuptools import setup, find_packages, Extension
from distutils.command.build_py import build_py
import os, sys
import subprocess
IS_PYPY = '__pypy__' in sys.builtin_module_names
class vmprof_build(build_py, object):
def run(self):
super(vmprof_build, self).run()
BASEDIR = os.path.dirname(os.path.abspath(__file__))
if IS_PYPY:
ext_modules = [] # built-in
else:
extra_compile_args = []
extra_source_files = [
'src/symboltable.c',
]
if sys.platform == 'win32':
extra_source_files = [
'src/vmprof_main_win32.c',
] # remove the native source files
libraries = []
extra_compile_args = ['-DVMPROF_WINDOWS=1']
elif sys.platform == 'darwin':
libraries = []
extra_compile_args = ['-Wno-unused']
extra_compile_args += ['-DVMPROF_APPLE=1']
extra_compile_args += ['-DVMPROF_UNIX=1']
# overwrite the optimization level, if it is not optimized enough,
# it might use the regiter rbx...
extra_compile_args += ['-g']
extra_compile_args += ['-O2']
elif sys.platform.startswith('linux'):
libraries = ['dl','unwind']
extra_compile_args = ['-Wno-unused']
extra_compile_args += ['-DVMPROF_LINUX=1']
extra_compile_args += ['-DVMPROF_UNIX=1']
if sys.maxsize == 2**63-1:
libraries.append('unwind-x86_64')
else:
libraries.append('unwind-x86')
extra_source_files += [
'src/libbacktrace/backtrace.c',
'src/libbacktrace/state.c',
'src/libbacktrace/elf.c',
'src/libbacktrace/dwarf.c',
'src/libbacktrace/fileline.c',
'src/libbacktrace/mmap.c',
'src/libbacktrace/mmapio.c',
'src/libbacktrace/posix.c',
'src/libbacktrace/sort.c',
]
# configure libbacktrace!!
class vmprof_build(build_py, object):
def run(self):
orig_dir = os.getcwd()
os.chdir(os.path.join(BASEDIR, "src", "libbacktrace"))
subprocess.check_call(["./configure"])
os.chdir(orig_dir)
super(vmprof_build, self).run()
else:
raise NotImplementedError("platform '%s' is not supported!" % sys.platform)
extra_compile_args.append('-I src/')
extra_compile_args.append('-I src/libbacktrace')
ext_modules = [Extension('_vmprof',
sources=[
'src/_vmprof.c',
'src/machine.c',
'src/compat.c',
'src/vmp_stack.c',
] + extra_source_files,
depends=[
'src/vmprof_main.h',
'src/vmprof_main_32.h',
'src/vmprof_mt.h',
'src/vmprof_common.h',
],
extra_compile_args=extra_compile_args,
libraries=libraries)]
if sys.version_info[:2] >= (3, 3):
extra_install_requires = []
else:
extra_install_requires = ["backports.shutil_which"]
setup(
name='vmprof',
author='vmprof team',
author_email='[email protected]',
version="0.4.5",
packages=find_packages(),
description="Python's vmprof client",
long_description='See https://vmprof.readthedocs.org/',
url='https://github.com/vmprof/vmprof-python',
cmdclass={'build_py': vmprof_build},
install_requires=[
'requests',
'six',
'pytz',
'colorama',
] + extra_install_requires,
tests_require=['pytest','cffi','hypothesis'],
entry_points = {
'console_scripts': [
'vmprofshow = vmprof.show:main'
]},
classifiers=[
'License :: OSI Approved :: MIT License',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
],
zip_safe=False,
include_package_data=True,
ext_modules=ext_modules,
)