This repository was archived by the owner on Jan 1, 2025. It is now read-only.
forked from DataDog/dd-trace-py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
163 lines (134 loc) · 5.11 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
import copy
import os
import sys
from distutils.command.build_ext import build_ext
from distutils.errors import CCompilerError, DistutilsExecError, DistutilsPlatformError
from setuptools import setup, find_packages, Extension
from setuptools.command.test import test as TestCommand
class Tox(TestCommand):
user_options = [('tox-args=', 'a', 'Arguments to pass to tox')]
def initialize_options(self):
TestCommand.initialize_options(self)
self.tox_args = None
def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True
def run_tests(self):
# import here, cause outside the eggs aren't loaded
import tox
import shlex
args = self.tox_args
if args:
args = shlex.split(self.tox_args)
errno = tox.cmdline(args=args)
sys.exit(errno)
long_description = """
# dd-trace-py
`ddtrace` is Datadog's tracing library for Python. It is used to trace requests
as they flow across web servers, databases and microservices so that developers
have great visiblity into bottlenecks and troublesome requests.
## Getting Started
For a basic product overview, installation and quick start, check out our
[setup documentation][setup docs].
For more advanced usage and configuration, check out our [API
documentation][pypi docs].
For descriptions of terminology used in APM, take a look at the [official
documentation][visualization docs].
[setup docs]: https://docs.datadoghq.com/tracing/setup/python/
[pypi docs]: http://pypi.datadoghq.com/trace/docs/
[visualization docs]: https://docs.datadoghq.com/tracing/visualization/
"""
# Base `setup()` kwargs without any C-extension registering
setup_kwargs = dict(
name='ddtrace',
description='Datadog tracing code',
url='https://github.com/DataDog/dd-trace-py',
author='Datadog, Inc.',
author_email='dev@datadoghq.com',
long_description=long_description,
long_description_content_type='text/markdown',
license='BSD',
packages=find_packages(exclude=['tests*']),
install_requires=[
'psutil>=5.0.0',
],
extras_require={
# users can include opentracing by having:
# install_requires=['ddtrace[opentracing]', ...]
'opentracing': ['opentracing>=2.0.0'],
},
# plugin tox
tests_require=['tox', 'flake8'],
cmdclass={'test': Tox},
entry_points={
'console_scripts': [
'ddtrace-run = ddtrace.commands.ddtrace_run:main'
]
},
classifiers=[
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
],
use_scm_version=True,
setup_requires=['setuptools_scm'],
)
# The following from here to the end of the file is borrowed from wrapt's and msgpack's `setup.py`:
# https://github.com/GrahamDumpleton/wrapt/blob/4ee35415a4b0d570ee6a9b3a14a6931441aeab4b/setup.py
# https://github.com/msgpack/msgpack-python/blob/381c2eff5f8ee0b8669fd6daf1fd1ecaffe7c931/setup.py
# These helpers are useful for attempting build a C-extension and then retrying without it if it fails
libraries = []
if sys.platform == 'win32':
libraries.append('ws2_32')
build_ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError, IOError, OSError)
else:
build_ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError)
class BuildExtFailed(Exception):
pass
# Attempt to build a C-extension, catch and throw a common/custom error if there are any issues
class optional_build_ext(build_ext):
def run(self):
try:
build_ext.run(self)
except DistutilsPlatformError:
raise BuildExtFailed()
def build_extension(self, ext):
try:
build_ext.build_extension(self, ext)
except build_ext_errors:
raise BuildExtFailed()
macros = []
if sys.byteorder == 'big':
macros = [('__BIG_ENDIAN__', '1')]
else:
macros = [('__LITTLE_ENDIAN__', '1')]
# Try to build with C extensions first, fallback to only pure-Python if building fails
try:
kwargs = copy.deepcopy(setup_kwargs)
kwargs['ext_modules'] = [
Extension(
'ddtrace.vendor.wrapt._wrappers',
sources=['ddtrace/vendor/wrapt/_wrappers.c'],
),
Extension(
'ddtrace.vendor.msgpack._cmsgpack',
sources=['ddtrace/vendor/msgpack/_cmsgpack.cpp'],
libraries=libraries,
include_dirs=['ddtrace/vendor/'],
define_macros=macros,
),
]
# DEV: Make sure `cmdclass` exists
kwargs.setdefault('cmdclass', dict())
kwargs['cmdclass']['build_ext'] = optional_build_ext
setup(**kwargs)
except BuildExtFailed:
# Set `DDTRACE_BUILD_TRACE=TRUE` in CI to raise any build errors
if os.environ.get('DDTRACE_BUILD_RAISE') == 'TRUE':
raise
print('WARNING: Failed to install wrapt/msgpack C-extensions, using pure-Python wrapt/msgpack instead')
setup(**setup_kwargs)