@@ -1,47 +1,85 @@
1−{ lib, buildPythonPackage, fetchPypi, python, pythonOlder
1+{ stdenv, lib, buildPythonPackage, fetchFromGitHub, python, pythonOlder
22, cython
33, eventlet
44, futures
5+, iana-etc
6+, geomet
57, libev
68, mock
79, nose
8−, pytest
10+, pytestCheckHook
911, pytz
1012, pyyaml
1113, scales
1214, six
1315, sure
16+, gremlinpython
17+, gevent
18+, twisted
19+, libredirect
1420}:
1521
1622buildPythonPackage rec {
1723 pname = "cassandra-driver";
1824 version = "3.24.0";
1925
20− src = fetchPypi {
21− inherit pname version;
22− sha256 = "83ec8d9a5827ee44bb1c0601a63696a8a9086beaf0151c8255556299246081bd";
26+ # pypi tarball doesn't include tests
27+ src = fetchFromGitHub {
28+ owner = "datastax";
29+ repo = "python-driver";
30+ rev = version;
31+ sha256 = "1rr69hly5q810xpn8rkzxwzlq55wxxp7kwki9vfri3gh674d2wip";
2332 };
2433
2534 nativeBuildInputs = [ cython ];
2635 buildInputs = [ libev ];
27− propagatedBuildInputs = [ six ]
36+ propagatedBuildInputs = [ six geomet ]
2837 ++ lib.optionals (pythonOlder "3.4") [ futures ];
2938
30− checkInputs = [ eventlet mock nose pytest pytz pyyaml sure ];
31−
32− # ignore test files which try to do socket.getprotocolname('tcp')
33− # as it fails in sandbox mode due to lack of a /etc/protocols file
34− checkPhase = ''
35− pytest tests/unit \
36− --ignore=tests/unit/io/test_libevreactor.py \
37− --ignore=tests/unit/io/test_eventletreactor.py \
38− --ignore=tests/unit/io/test_asyncorereactor.py
39+ # Make /etc/protocols accessible to allow socket.getprotobyname('tcp') in sandbox,
40+ # also /etc/resolv.conf is referenced by some tests
41+ preCheck = (stdenv.lib.optionalString stdenv.isLinux ''
42+ echo "nameserver 127.0.0.1" > resolv.conf
43+ export NIX_REDIRECTS=/etc/protocols=${iana-etc}/etc/protocols:/etc/resolv.conf=$(realpath resolv.conf)
44+ export LD_PRELOAD=${libredirect}/lib/libredirect.so
45+ '') + ''
46+ # increase tolerance for time-based test
47+ substituteInPlace tests/unit/io/utils.py --replace 'delta=.15' 'delta=.3'
48+ '';
49+ postCheck = ''
50+ unset NIX_REDIRECTS LD_PRELOAD
3951 '';
4052
53+ checkInputs = [
54+ pytestCheckHook
55+ eventlet
56+ mock
57+ nose
58+ pytz
59+ pyyaml
60+ sure
61+ scales
62+ gremlinpython
63+ gevent
64+ twisted
65+ ];
66+
67+ pytestFlagsArray = [
68+ "tests/unit"
69+ # requires puresasl
70+ "--ignore=tests/unit/advanced/test_auth.py"
71+ ];
72+ disabledTests = [
73+ # doesn't seem to be intended to be run directly
74+ "_PoolTests"
75+ # attempts to make connection to localhost
76+ "test_connection_initialization"
77+ ];
78+
4179 meta = with lib; {
4280 description = "A Python client driver for Apache Cassandra";
4381 homepage = "http://datastax.github.io/python-driver";
4482 license = licenses.asl20;
45− broken = true; # geomet doesn't exist
83+ maintainers = with maintainers; [ turion ris ];
4684 };
4785}