forked from datastax/python-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
200 lines (158 loc) · 5.91 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
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
import os
import sys
import warnings
try:
import subprocess
has_subprocess = True
except ImportError:
has_subprocess = False
from distribute_setup import use_setuptools
use_setuptools()
from setuptools import setup, Feature
from distutils.command.build_ext import build_ext
from distutils.core import Extension
from distutils.errors import (CCompilerError, DistutilsPlatformError,
DistutilsExecError)
from distutils.cmd import Command
from cassandra import __version__
long_description = ""
with open("README.rst") as f:
long_description = f.read()
class doc(Command):
description = "generate or test documentation"
user_options = [("test", "t",
"run doctests instead of generating documentation")]
boolean_options = ["test"]
def initialize_options(self):
self.test = False
def finalize_options(self):
pass
def run(self):
if self.test:
path = "docs/_build/doctest"
mode = "doctest"
else:
path = "docs/_build/%s" % __version__
mode = "html"
try:
os.makedirs(path)
except:
pass
if has_subprocess:
try:
output = subprocess.check_output(
["sphinx-build", "-b", mode, "docs", path],
stderr=subprocess.STDOUT)
except subprocess.CalledProcessError, exc:
raise RuntimeError("Documentation step '%s' failed: %s: %s" % (mode, exc, exc.output))
else:
print output
print ""
print "Documentation step '%s' performed, results here:" % mode
print " %s/" % path
class build_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
===============================================================================
"""
def run(self):
try:
build_ext.run(self)
except DistutilsPlatformError, exc:
sys.stderr.write('%s\n' % str(exc))
warnings.warn(self.error_message % "C extensions.")
def build_extension(self, ext):
try:
build_ext.build_extension(self, ext)
except (CCompilerError, DistutilsExecError,
DistutilsPlatformError, IOError), exc:
sys.stderr.write('%s\n' % str(exc))
name = "The %s extension" % (ext.name,)
warnings.warn(self.error_message % (name,))
murmur3_ext = Feature(
"Token-aware routing support for Murmur3",
standard=True,
ext_modules=[Extension('cassandra.murmur3',
sources=['cassandra/murmur3.c'])])
libev_support = Feature(
"Libev event loop support",
standard=True,
ext_modules=[Extension('cassandra.io.libevwrapper',
sources=['cassandra/io/libevwrapper.c'],
include_dirs=['/usr/include/libev'],
libraries=['ev']
)])
features = {
"murmur3": murmur3_ext,
"libev": libev_support,
}
if "--no-extensions" in sys.argv:
sys.argv = [a for a in sys.argv if a != "--no-extensions"]
features = {}
elif "--no-murmur3" in sys.argv:
sys.argv = [a for a in sys.argv if a != "--no-murmur3"]
features.pop("murmur3")
elif "--no-libev" in sys.argv:
sys.argv = [a for a in sys.argv if a != "--no-libev"]
features.pop("libev")
if (sys.platform.startswith("java")
or sys.platform == "cli"
or "PyPy" in sys.version):
sys.stderr.write("""
===============================================================================
The optional C extensions are not supported on this platform.
===============================================================================
""")
features = {}
elif sys.byteorder == "big":
sys.stderr.write("""
===============================================================================
The optional C extensions are not supported on big-endian systems.
===============================================================================
""")
features = {}
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"],
features=features,
install_requires=['futures', 'scales'],
tests_require=['nose', 'mock', 'ccm'],
cmdclass={"build_ext": build_extensions,
"doc": doc},
classifiers=[
'Development Status :: 3 - Alpha',
'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'
]
)