1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 cryptography,
6 cython_0,
7 eventlet,
8 fetchFromGitHub,
9 geomet,
10 gevent,
11 gremlinpython,
12 iana-etc,
13 libev,
14 libredirect,
15 mock,
16 nose,
17 pytestCheckHook,
18 pythonOlder,
19 pytz,
20 pyyaml,
21 scales,
22 six,
23 sure,
24 twisted,
25}:
26
27buildPythonPackage rec {
28 pname = "cassandra-driver";
29 version = "3.29.1";
30 format = "setuptools";
31
32 disabled = pythonOlder "3.7";
33
34 src = fetchFromGitHub {
35 owner = "datastax";
36 repo = "python-driver";
37 rev = "refs/tags/${version}";
38 hash = "sha256-pnNm5Pd5k4bt+s3GrUUDWRpSdqNSM89GiX8DZKYzW1E=";
39 };
40
41 postPatch = ''
42 substituteInPlace setup.py \
43 --replace 'geomet>=0.1,<0.3' 'geomet'
44 '';
45
46 nativeBuildInputs = [ cython_0 ];
47
48 buildInputs = [ libev ];
49
50 propagatedBuildInputs = [
51 six
52 geomet
53 ];
54
55 nativeCheckInputs = [
56 pytestCheckHook
57 mock
58 nose
59 pytz
60 pyyaml
61 sure
62 ] ++ lib.flatten (lib.attrValues passthru.optional-dependencies);
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.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 ];
96
97 disabledTests = [
98 # doesn't seem to be intended to be run directly
99 "_PoolTests"
100 # attempts to make connection to localhost
101 "test_connection_initialization"
102 # time-sensitive
103 "test_nts_token_performance"
104 ];
105
106 passthru.optional-dependencies = {
107 cle = [ cryptography ];
108 eventlet = [ eventlet ];
109 gevent = [ gevent ];
110 graph = [ gremlinpython ];
111 metrics = [ scales ];
112 twisted = [ twisted ];
113 };
114
115 meta = with lib; {
116 description = "A Python client driver for Apache Cassandra";
117 homepage = "http://datastax.github.io/python-driver";
118 changelog = "https://github.com/datastax/python-driver/blob/${version}/CHANGELOG.rst";
119 license = licenses.asl20;
120 maintainers = with maintainers; [ ris ];
121 };
122}