forked from apache/cassandra-python-driver
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
Latest commit
223 lines (172 loc) · 6.53 KB
/
Copy pathsetup.py
File metadata and controls
223 lines (172 loc) · 6.53 KB
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
importplatform
importos
importsys
importwarnings
try:
importsubprocess
has_subprocess=True
exceptImportError:
has_subprocess=False
importez_setup
ez_setup.use_setuptools()
fromsetuptoolsimportsetup
fromdistutils.command.build_extimportbuild_ext
fromdistutils.coreimportExtension
fromdistutils.errorsimport (CCompilerError, DistutilsPlatformError,
DistutilsExecError)
fromdistutils.cmdimportCommand
fromcassandraimport__version__
long_description=""
withopen("README.rst") asf:
long_description=f.read()
classDocCommand(Command):
description="generate or test documentation"
user_options= [("test", "t",
"run doctests instead of generating documentation")]
boolean_options= ["test"]
definitialize_options(self):
self.test=False
deffinalize_options(self):
pass
defrun(self):
ifself.test:
path="docs/_build/doctest"
mode="doctest"
else:
path="docs/_build/%s"%__version__
mode="html"
try:
os.makedirs(path)
except:
pass
ifhas_subprocess:
try:
output=subprocess.check_output(
["sphinx-build", "-b", mode, "docs", path],
stderr=subprocess.STDOUT)
exceptsubprocess.CalledProcessErrorasexc:
raiseRuntimeError("Documentation step '%s' failed: %s: %s"% (mode, exc, exc.output))
else:
printoutput
print""
print"Documentation step '%s' performed, results here:"%mode
print" %s/"%path
classBuildFailed(Exception):
def__init__(self, ext):
self.ext=ext
murmur3_ext=Extension('cassandra.murmur3',
sources=['cassandra/murmur3.c'])
libev_ext=Extension('cassandra.io.libevwrapper',
sources=['cassandra/io/libevwrapper.c'],
include_dirs=['/usr/include/libev'],
libraries=['ev'])
classbuild_extensions(build_ext):
error_message="""
===============================================================================
WARNING: could not compile %s.
The C extensions are not required for the driver to run, but they add support
for libev and token-aware routing with the Murmur3Partitioner.
Linux users should ensure that GCC and the Python headers are available.
On Ubuntu and Debian, this can be accomplished by running:
$ sudo apt-get install build-essential python-dev
On RedHat and RedHat-based systems like CentOS and Fedora:
$ sudo yum install gcc python-devel
On OSX, homebrew installations of Python should provide the necessary headers.
libev Support
-------------
For libev support, you will also need to install libev and its headers.
On Debian/Ubuntu:
$ sudo apt-get install libev4 libev-dev
On RHEL/CentOS/Fedora:
$ sudo yum install libev libev-devel
On OSX, via homebrew:
$ brew install libev
===============================================================================
"""
defrun(self):
try:
build_ext.run(self)
exceptDistutilsPlatformErrorasexc:
sys.stderr.write('%s\n'%str(exc))
warnings.warn(self.error_message%"C extensions.")
defbuild_extension(self, ext):
try:
build_ext.build_extension(self, ext)
except (CCompilerError, DistutilsExecError,
DistutilsPlatformError, IOError) asexc:
sys.stderr.write('%s\n'%str(exc))
name="The %s extension"% (ext.name,)
warnings.warn(self.error_message% (name,))
raiseBuildFailed(ext)
defrun_setup(extensions):
kw= {'cmdclass': {'doc': DocCommand}}
ifextensions:
kw['cmdclass']['build_ext'] =build_extensions
kw['ext_modules'] =extensions
dependencies= ['futures', 'scales', 'blist']
ifplatform.python_implementation() !="CPython":
dependencies.remove('blist')
setup(
name='cassandra-driver',
version=__version__,
description='Python driver for Cassandra',
long_description=long_description,
url='http://github.com/datastax/python-driver',
author='Tyler Hobbs',
author_email='tyler@datastax.com',
packages=['cassandra', 'cassandra.io'],
include_package_data=True,
install_requires=dependencies,
tests_require=['nose', 'mock', 'ccm', 'unittest2', 'PyYAML'],
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Natural Language :: English',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Topic :: Software Development :: Libraries :: Python Modules'
],
**kw)
extensions= [murmur3_ext, libev_ext]
if"--no-extensions"insys.argv:
sys.argv= [aforainsys.argvifa!="--no-extensions"]
extensions= []
elif"--no-murmur3"insys.argv:
sys.argv= [aforainsys.argvifa!="--no-murmur3"]
extensions.remove(murmur3_ext)
elif"--no-libev"insys.argv:
sys.argv= [aforainsys.argvifa!="--no-libev"]
extensions.remove(libev_ext)
platform_unsupported_msg= \
"""
===============================================================================
The optional C extensions are not supported on this platform.
===============================================================================
"""
arch_unsupported_msg= \
"""
===============================================================================
The optional C extensions are not supported on big-endian systems.
===============================================================================
"""
ifextensions:
if (sys.platform.startswith("java")
orsys.platform=="cli"
or"PyPy"insys.version):
sys.stderr.write(platform_unsupported_msg)
extensions= ()
elifsys.byteorder=="big":
sys.stderr.write(arch_unsupported_msg)
extensions= ()
whileTrue:
# try to build as many of the extensions as we can
try:
run_setup(extensions)
exceptBuildFailedasfailure:
extensions.remove(failure.ext)
else:
break