-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
103 lines (83 loc) · 3.3 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
#!/usr/bin/env python3
"""
SPDX-License-Identifier: LGPL-2.1
Copyright 2019 VMware Inc, Yordan Karadzhov (VMware) <[email protected]>
"""
import sys
from setuptools import setup, find_packages
from distutils.core import Extension
from Cython.Build import cythonize
import pkgconfig as pkg
import numpy as np
def version_check(lib, lib_version, min_version):
min_v = min_version.split('.')
lib_v = pkg.modversion(lib).split('.')
if lib_v[2] == 'dev':
lib_v[2] = '0'
if tuple(map(int, lib_v)) < tuple(map(int, min_v)):
print('{0} v{1} is required'.format(lib, min_version))
return False
return True
def add_library(lib, min_version,
libs_found,
library_dirs,
include_dirs):
pkg_info = pkg.parse(lib)
lib_version = pkg.modversion(lib)
if version_check(lib, lib_version, min_version):
include_dirs.extend(pkg_info['include_dirs'])
library_dirs.extend(pkg_info['library_dirs'])
libs_found.extend([(lib, lib_version)])
def third_party_paths():
library_dirs = ['$ORIGIN','tracecruncher']
include_dirs = [np.get_include()]
libs_required = [('libtraceevent', '1.7.3'),
('libtracefs', '1.7.0'),
('libkshark', '2.0.1')]
libs_found = []
for lib in libs_required:
add_library(lib[0], lib[1],
libs_found,
library_dirs,
include_dirs)
if len(libs_found) < len(libs_required):
sys.exit(1)
library_dirs = list(set(library_dirs))
return include_dirs, library_dirs
include_dirs, library_dirs = third_party_paths()
def extension(name, sources, libraries):
runtime_library_dirs = library_dirs
return Extension(name, sources=sources,
include_dirs=include_dirs,
library_dirs=library_dirs,
runtime_library_dirs=runtime_library_dirs,
libraries=libraries,
)
def main():
module_ft = extension(name='tracecruncher.ftracepy',
sources=['src/ftracepy.c', 'src/ftracepy-utils.c'],
libraries=['traceevent', 'tracefs', 'tcrunchbase', 'rt'])
cythonize('src/npdatawrapper.pyx', language_level = 3)
module_data = extension(name='tracecruncher.npdatawrapper',
sources=['src/npdatawrapper.c'],
libraries=['kshark'])
module_ks = extension(name='tracecruncher.ksharkpy',
sources=['src/ksharkpy.c', 'src/ksharkpy-utils.c'],
libraries=['kshark'])
setup(name='tracecruncher',
version='0.4.1',
description='Interface for accessing Linux tracing data in Python.',
author='Yordan Karadzhov (VMware)',
author_email='[email protected]',
url='https://github.com/vmware/trace-cruncher',
license='LGPL-2.1',
packages=find_packages(),
package_data={'tracecruncher': ['*.so']},
ext_modules=[module_ft, module_data, module_ks],
classifiers=[
'Development Status :: 4 - Beta',
'Programming Language :: Python :: 3',
]
)
if __name__ == '__main__':
main()