forked from pinpoint-apm/pinpoint-c-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_pypi.py
88 lines (75 loc) · 3.12 KB
/
setup_pypi.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
from setuptools import setup, Extension,find_packages
from distutils.command.build_ext import build_ext
import os,subprocess,sys
import platform
with open("README", "r") as fh:
long_description = fh.read()
if sys.version_info[0] == 3:
class CommonBuild(build_ext):
build_temp = 'build'
def build_common(self):
if not os.path.exists(CommonBuild.build_temp):
os.makedirs(CommonBuild.build_temp)
comm_path = os.path.abspath('common')
subprocess.check_call(['cmake','-DCMAKE_BUILD_TYPE=Debug',comm_path],cwd=CommonBuild.build_temp)
subprocess.check_call(['cmake', '--build', '.'], cwd=CommonBuild.build_temp)
def run(self):
try:
out = subprocess.check_output(['cmake', '--version'])
except OSError:
raise RuntimeError("CMake must be installed to build the following extensions: " +
", ".join(e.name for e in self.extensions))
self.build_common()
super().run()
pinpointBuild = CommonBuild
else:
class CommonBuild(build_ext,object):
build_temp = 'build'
def build_common(self):
if not os.path.exists(CommonBuild.build_temp):
os.makedirs(CommonBuild.build_temp)
comm_path = os.path.abspath('common')
subprocess.check_call(['cmake','-DCMAKE_BUILD_TYPE=Debug',comm_path],cwd=CommonBuild.build_temp)
subprocess.check_call(['cmake', '--build', '.'], cwd=CommonBuild.build_temp)
def run(self):
try:
out = subprocess.check_output(['cmake', '--version'])
except OSError:
raise RuntimeError("CMake must be installed to build the following extensions: " +
", ".join(e.name for e in self.extensions))
self.build_common()
super(CommonBuild,self).run()
pinpointBuild = CommonBuild
###############################################
# check os type
name = platform.system().lower()
agent_libraries = []
if name=='windows':
raise RuntimeError('pinpoint-c-agent currently not support MS')
elif name == 'darwin':
agent_libraries = ['pinpoint_common', 'stdc++']
elif name == 'linux':
agent_libraries = ['pinpoint_common','rt','stdc++']
else:
raise RuntimeError('Unknow platform to me: '+name)
###############################################
setup(name='pinpointPy',
version="1.0.14",
author="cd_pinpoint members",
author_email='[email protected]',
license='Apache License 2.0',
url="https://github.com/pinpoint-apm/pinpoint-c-agent",
long_description=long_description,
long_description_content_type='text/markdown',
ext_modules=[
Extension('_pinpointPy',
['src/PY/_pinpoint_py.c'],
include_dirs = ['common/include'],
library_dirs = [pinpointBuild.build_temp+"/lib"],
libraries = agent_libraries
)
],
package_dir={'':'plugins/PY'},
packages=find_packages(where='plugins/PY'),
cmdclass={'build_ext': pinpointBuild}
)