1{ 2 lib, 3 stdenv, 4 buildPythonPackage, 5 cryptography, 6 cython, 7 eventlet, 8 fetchFromGitHub, 9 geomet, 10 gevent, 11 gremlinpython, 12 iana-etc, 13 libev, 14 libredirect, 15 pytestCheckHook, 16 pytz, 17 pyyaml, 18 scales, 19 six, 20 sure, 21 twisted, 22 setuptools, 23 distutils, 24 pythonAtLeast, 25}: 26 27buildPythonPackage rec { 28 pname = "cassandra-driver"; 29 version = "3.29.2"; 30 pyproject = true; 31 32 src = fetchFromGitHub { 33 owner = "datastax"; 34 repo = "python-driver"; 35 tag = version; 36 hash = "sha256-RX9GLk2admzRasmP7LCwIfsJIt8TC/9rWhIcoTqS0qc="; 37 }; 38 39 pythonRelaxDeps = [ "geomet" ]; 40 41 build-system = [ 42 distutils 43 setuptools 44 cython 45 ]; 46 47 buildInputs = [ libev ]; 48 49 dependencies = [ 50 six 51 geomet 52 ]; 53 54 nativeCheckInputs = [ 55 pytestCheckHook 56 pytz 57 pyyaml 58 sure 59 ] ++ lib.flatten (lib.attrValues optional-dependencies); 60 61 # This is used to determine the version of cython that can be used 62 CASS_DRIVER_ALLOWED_CYTHON_VERSION = cython.version; 63 64 # Make /etc/protocols accessible to allow socket.getprotobyname('tcp') in sandbox, 65 # also /etc/resolv.conf is referenced by some tests 66 preCheck = 67 (lib.optionalString stdenv.hostPlatform.isLinux '' 68 echo "nameserver 127.0.0.1" > resolv.conf 69 export NIX_REDIRECTS=/etc/protocols=${iana-etc}/etc/protocols:/etc/resolv.conf=$(realpath resolv.conf) 70 export LD_PRELOAD=${libredirect}/lib/libredirect.so 71 '') 72 + '' 73 # increase tolerance for time-based test 74 substituteInPlace tests/unit/io/utils.py --replace 'delta=.15' 'delta=.3' 75 76 export HOME=$(mktemp -d) 77 # cythonize this before we hide the source dir as it references 78 # one of its files 79 cythonize -i tests/unit/cython/types_testhelper.pyx 80 81 mv cassandra .cassandra.hidden 82 ''; 83 84 pythonImportsCheck = [ "cassandra" ]; 85 86 postCheck = '' 87 unset NIX_REDIRECTS LD_PRELOAD 88 ''; 89 90 pytestFlagsArray = [ "tests/unit" ]; 91 92 disabledTestPaths = [ 93 # requires puresasl 94 "tests/unit/advanced/test_auth.py" 95 # Uses asyncore, which is deprecated in python 3.12+ 96 "tests/unit/io/test_asyncorereactor.py" 97 ]; 98 99 disabledTests = [ 100 # doesn't seem to be intended to be run directly 101 "_PoolTests" 102 # attempts to make connection to localhost 103 "test_connection_initialization" 104 # time-sensitive 105 "test_nts_token_performance" 106 ]; 107 108 optional-dependencies = { 109 cle = [ cryptography ]; 110 eventlet = [ eventlet ]; 111 gevent = [ gevent ]; 112 graph = [ gremlinpython ]; 113 metrics = [ scales ]; 114 twisted = [ twisted ]; 115 }; 116 117 meta = { 118 # cassandra/io/libevwrapper.c:668:10: error: implicit declaration of function ‘PyEval_ThreadsInitialized’ [] 119 broken = pythonAtLeast "3.13"; 120 description = "Python client driver for Apache Cassandra"; 121 homepage = "http://datastax.github.io/python-driver"; 122 changelog = "https://github.com/datastax/python-driver/blob/${version}/CHANGELOG.rst"; 123 license = lib.licenses.asl20; 124 maintainers = with lib.maintainers; [ ris ]; 125 }; 126}