1{ stdenv
2, lib
3, buildPythonPackage
4, fetchFromGitHub
5, pythonOlder
6, cython
7, eventlet
8, futures ? null
9, iana-etc
10, geomet
11, libev
12, mock
13, nose
14, pytestCheckHook
15, pytz
16, pyyaml
17, scales
18, six
19, sure
20, gremlinpython
21, gevent
22, twisted
23, libredirect
24}:
25
26buildPythonPackage rec {
27 pname = "cassandra-driver";
28 version = "3.25.0";
29
30 # pypi tarball doesn't include tests
31 src = fetchFromGitHub {
32 owner = "datastax";
33 repo = "python-driver";
34 rev = version;
35 sha256 = "1dn7iiavsrhh6i9hcyw0mk8j95r5ym0gbrvdca998hx2rnz5ark6";
36 };
37
38 postPatch = ''
39 substituteInPlace setup.py --replace 'geomet>=0.1,<0.3' 'geomet'
40 '';
41
42 nativeBuildInputs = [ cython ];
43 buildInputs = [ libev ];
44 propagatedBuildInputs = [ six geomet ]
45 ++ lib.optionals (pythonOlder "3.4") [ futures ];
46
47 # Make /etc/protocols accessible to allow socket.getprotobyname('tcp') in sandbox,
48 # also /etc/resolv.conf is referenced by some tests
49 preCheck = (lib.optionalString stdenv.isLinux ''
50 echo "nameserver 127.0.0.1" > resolv.conf
51 export NIX_REDIRECTS=/etc/protocols=${iana-etc}/etc/protocols:/etc/resolv.conf=$(realpath resolv.conf)
52 export LD_PRELOAD=${libredirect}/lib/libredirect.so
53 '') + ''
54 # increase tolerance for time-based test
55 substituteInPlace tests/unit/io/utils.py --replace 'delta=.15' 'delta=.3'
56 '';
57 postCheck = ''
58 unset NIX_REDIRECTS LD_PRELOAD
59 '';
60
61 checkInputs = [
62 pytestCheckHook
63 eventlet
64 mock
65 nose
66 pytz
67 pyyaml
68 sure
69 scales
70 gremlinpython
71 gevent
72 twisted
73 ];
74
75 pytestFlagsArray = [
76 "tests/unit"
77 ];
78 disabledTestPaths = [
79 # requires puresasl
80 "tests/unit/advanced/test_auth.py"
81 ];
82 disabledTests = [
83 # doesn't seem to be intended to be run directly
84 "_PoolTests"
85 # attempts to make connection to localhost
86 "test_connection_initialization"
87 # time-sensitive
88 "test_nts_token_performance"
89 ];
90
91 meta = with lib; {
92 description = "A Python client driver for Apache Cassandra";
93 homepage = "http://datastax.github.io/python-driver";
94 license = licenses.asl20;
95 maintainers = with maintainers; [ turion ris ];
96 };
97}