-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsetup.py
66 lines (61 loc) · 2.32 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
from setuptools import Extension, setup
from setuptools.command.build_ext import build_ext
import pathlib, os, shutil, glob
class CMakeExtension(Extension):
def __init__(self, name):
# don't invoke the original build_ext for this special extension
super().__init__(name, sources=[])
class cmake_build_ext(build_ext):
def run(self):
for ext in self.extensions:
if not isinstance(ext, CMakeExtension):
raise TypeError('ext type {0} mismatch intended CMakeExtension'.format(type(ext)))
self.build_cmake(ext)
def build_cmake(self, ext):
build_temp = pathlib.Path(self.build_temp)
build_temp.mkdir(parents=True, exist_ok=True)
extdir = os.path.abspath(
os.path.dirname(self.get_ext_fullpath(ext.name)))
archive_out_dir = str(os.path.join(extdir, 'cppkin'))
config = 'Debug' if self.debug else 'Release'
cmake_args = [
'-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=' + archive_out_dir,
'-D3RD_PARTY_INSTALL_STEP=ON',
'-DCOMPILATION_STEP=ON',
'-DWITH_PYTHON=ON',
'-DPYTHON_BINDING=pyBind',
'-DCMAKE_BUILD_TYPE=' + config,
'-DFORCE_INSTALL_RPATH=ON'
]
cwd = pathlib.Path().absolute()
build_temp_rel = os.path.relpath(cwd, build_temp)
os.chdir(str(build_temp))
self.spawn(['cmake', str(build_temp_rel)] + cmake_args)
self.spawn(['make'])
os.chdir(str(cwd))
for file in glob.glob(str(build_temp / 'Third_Party' / 'lib') + '/*.so'):
shutil.copy2(file, archive_out_dir)
setup(
name='cppkin',
version='1.1.2',
description='zipkin tracing library',
url='https://github.com/Dudi119/cppKin',
author='David (Dudi) Likvornik',
author_email='[email protected]',
license='Apache 2.0',
classifiers=[
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
],
keywords='zipkin instrumentation tracing',
packages=['cppkin'],
ext_modules=[CMakeExtension('cppKin')],
include_package_data=True,
cmdclass={
'build_ext': cmake_build_ext
},
long_description="""
cppkin is an instrumentation client library for zipkin available in C++ and Python.
"""
)