1{ lib
2, stdenv
3, buildPythonPackage
4, cython
5, eventlet
6, fetchFromGitHub
7, geomet
8, gevent
9, gremlinpython
10, iana-etc
11, libev
12, libredirect
13, mock
14, nose
15, pytestCheckHook
16, pythonOlder
17, pytz
18, pyyaml
19, scales
20, six
21, sure
22, twisted
23}:
24
25buildPythonPackage rec {
26 pname = "cassandra-driver";
27 version = "3.26.0";
28 format = "setuptools";
29
30 disabled = pythonOlder "3.7";
31
32 src = fetchFromGitHub {
33 owner = "datastax";
34 repo = "python-driver";
35 rev = "refs/tags/${version}";
36 hash = "sha256-mLQEG41WyFtXY2PJzoM4uaI4Cm+0xSIAPGhijHHbTBk=";
37 };
38
39 postPatch = ''
40 substituteInPlace setup.py \
41 --replace 'geomet>=0.1,<0.3' 'geomet'
42 '';
43
44 nativeBuildInputs = [
45 cython
46 ];
47
48 buildInputs = [
49 libev
50 ];
51
52 propagatedBuildInputs = [
53 six
54 geomet
55 ];
56
57 nativeCheckInputs = [
58 pytestCheckHook
59 eventlet
60 mock
61 nose
62 pytz
63 pyyaml
64 sure
65 scales
66 gremlinpython
67 gevent
68 twisted
69 ];
70
71 # Make /etc/protocols accessible to allow socket.getprotobyname('tcp') in sandbox,
72 # also /etc/resolv.conf is referenced by some tests
73 preCheck = (lib.optionalString stdenv.isLinux ''
74 echo "nameserver 127.0.0.1" > resolv.conf
75 export NIX_REDIRECTS=/etc/protocols=${iana-etc}/etc/protocols:/etc/resolv.conf=$(realpath resolv.conf)
76 export LD_PRELOAD=${libredirect}/lib/libredirect.so
77 '') + ''
78 # increase tolerance for time-based test
79 substituteInPlace tests/unit/io/utils.py --replace 'delta=.15' 'delta=.3'
80 '';
81
82 pythonImportsCheck = [
83 "cassandra"
84 ];
85
86 postCheck = ''
87 unset NIX_REDIRECTS LD_PRELOAD
88 '';
89
90 pytestFlagsArray = [
91 "tests/unit"
92 ];
93
94 disabledTestPaths = [
95 # requires puresasl
96 "tests/unit/advanced/test_auth.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 meta = with lib; {
109 description = "A Python client driver for Apache Cassandra";
110 homepage = "http://datastax.github.io/python-driver";
111 changelog = "https://github.com/datastax/python-driver/blob/${version}/CHANGELOG.rst";
112 license = licenses.asl20;
113 maintainers = with maintainers; [ turion ris ];
114 };
115}