Add optional cythonized core driver files.
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -17,6 +17,9 @@ tests/integration/ccm
|
||||
setuptools*.tar.gz
|
||||
setuptools*.egg
|
||||
|
||||
cassandra/*.c
|
||||
!cassandra/murmur3.c
|
||||
|
||||
# OSX
|
||||
.DS_Store
|
||||
|
||||
|
@@ -48,13 +48,15 @@ if six.PY3:
|
||||
def varint_unpack(term):
|
||||
val = int(''.join("%02x" % i for i in term), 16)
|
||||
if (term[0] & 128) != 0:
|
||||
val -= 1 << (len(term) * 8)
|
||||
len_term = len(term) # pulling this out of the expression to avoid overflow in cython optimized code
|
||||
val -= 1 << (len_term * 8)
|
||||
return val
|
||||
else:
|
||||
def varint_unpack(term): # noqa
|
||||
val = int(term.encode('hex'), 16)
|
||||
if (ord(term[0]) & 128) != 0:
|
||||
val = val - (1 << (len(term) * 8))
|
||||
len_term = len(term) # pulling this out of the expression to avoid overflow in cython optimized code
|
||||
val = val - (1 << (len_term * 8))
|
||||
return val
|
||||
|
||||
|
||||
|
28
setup.py
28
setup.py
@@ -234,16 +234,28 @@ def run_setup(extensions):
|
||||
],
|
||||
**kw)
|
||||
|
||||
extensions = [murmur3_ext, libev_ext]
|
||||
extensions = []
|
||||
|
||||
if "--no-murmur3" not in sys.argv:
|
||||
extensions.append(murmur3_ext)
|
||||
|
||||
if "--no-libev" not in sys.argv:
|
||||
extensions.append(libev_ext)
|
||||
|
||||
if "--no-cython" not in sys.argv:
|
||||
try:
|
||||
from Cython.Build import cythonize
|
||||
cython_candidates = ['cluster', 'concurrent', 'connection', 'cqltypes', 'marshal', 'metadata', 'pool', 'protocol', 'query', 'util']
|
||||
extensions.extend(cythonize(
|
||||
[Extension('cassandra.%s' % m, ['cassandra/%s.py' % m], extra_compile_args=['-Wno-unused-function']) for m in cython_candidates],
|
||||
exclude_failures=True))
|
||||
except ImportError:
|
||||
warnings.warn("Cython is not installed. Not compiling core driver files as extensions (optional).")
|
||||
|
||||
if "--no-extensions" in sys.argv:
|
||||
sys.argv = [a for a in sys.argv if a != "--no-extensions"]
|
||||
extensions = []
|
||||
elif "--no-murmur3" in sys.argv:
|
||||
sys.argv = [a for a in sys.argv if a != "--no-murmur3"]
|
||||
extensions.remove(murmur3_ext)
|
||||
elif "--no-libev" in sys.argv:
|
||||
sys.argv = [a for a in sys.argv if a != "--no-libev"]
|
||||
extensions.remove(libev_ext)
|
||||
|
||||
sys.argv = [a for a in sys.argv if a not in ("--no-murmur3", "--no-libev", "--no-cython", "--no-extensions")]
|
||||
|
||||
is_windows = os.name == 'nt'
|
||||
if is_windows:
|
||||
|
Reference in New Issue
Block a user