Be more careful when Cython is available but NumPy is not
This commit is contained in:
@@ -2,4 +2,10 @@ try:
|
||||
from cassandra.rowparser import make_recv_results_rows
|
||||
HAVE_CYTHON = True
|
||||
except ImportError:
|
||||
HAVE_CYTHON = False
|
||||
HAVE_CYTHON = False
|
||||
|
||||
try:
|
||||
import numpy
|
||||
HAVE_NUMPY = True
|
||||
except ImportError:
|
||||
HAVE_NUMPY = False
|
||||
|
||||
@@ -40,7 +40,7 @@ from cassandra.cqltypes import (AsciiType, BytesType, BooleanType,
|
||||
TupleType, lookup_casstype, SimpleDateType,
|
||||
TimeType, ByteType, ShortType)
|
||||
from cassandra.policies import WriteType
|
||||
from cassandra.cython_deps import HAVE_CYTHON
|
||||
from cassandra.cython_deps import HAVE_CYTHON, HAVE_NUMPY
|
||||
from cassandra import util
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@@ -1039,14 +1039,17 @@ def cython_protocol_handler(colparser):
|
||||
|
||||
if HAVE_CYTHON:
|
||||
from cassandra.objparser import ListParser, LazyParser
|
||||
from cassandra.numpyparser import NumpyParser
|
||||
|
||||
ProtocolHandler = cython_protocol_handler(ListParser())
|
||||
LazyProtocolHandler = cython_protocol_handler(LazyParser())
|
||||
NumpyProtocolHandler = cython_protocol_handler(NumpyParser())
|
||||
else:
|
||||
# Use Python-based ProtocolHandler
|
||||
LazyProtocolHandler = None
|
||||
|
||||
|
||||
if HAVE_CYTHON and HAVE_NUMPY:
|
||||
from cassandra.numpyparser import NumpyParser
|
||||
NumpyProtocolHandler = cython_protocol_handler(NumpyParser())
|
||||
else:
|
||||
NumpyProtocolHandler = None
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
try:
|
||||
import tests.unit.cython.dummy_module
|
||||
except ImportError:
|
||||
have_cython = False
|
||||
else:
|
||||
have_cython = True
|
||||
from cassandra.cython_deps import HAVE_CYTHON, HAVE_NUMPY
|
||||
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
@@ -18,10 +13,11 @@ def cyimport(import_path):
|
||||
try:
|
||||
return __import__(import_path, fromlist=True)
|
||||
except ImportError:
|
||||
if have_cython:
|
||||
if HAVE_CYTHON:
|
||||
raise
|
||||
return None
|
||||
|
||||
# @cythontest
|
||||
# def test_something(self): ...
|
||||
cythontest = unittest.skipUnless(have_cython, 'Cython is not available')
|
||||
cythontest = unittest.skipUnless(HAVE_CYTHON, 'Cython is not available')
|
||||
numpytest = unittest.skipUnless(HAVE_CYTHON and HAVE_NUMPY, 'NumPy is not available')
|
||||
Reference in New Issue
Block a user