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