python3Packages.cassandra-driver: fix build & tests

This commit is contained in:
Robert Scott 2020-10-18 01:36:52 +01:00
parent 14b0dfd2fc
commit 04a96e3c8b

View File

@ -1,47 +1,85 @@
{ lib, buildPythonPackage, fetchPypi, python, pythonOlder { stdenv, lib, buildPythonPackage, fetchFromGitHub, python, pythonOlder
, cython , cython
, eventlet , eventlet
, futures , futures
, iana-etc
, geomet
, libev , libev
, mock , mock
, nose , nose
, pytest , pytestCheckHook
, pytz , pytz
, pyyaml , pyyaml
, scales , scales
, six , six
, sure , sure
, gremlinpython
, gevent
, twisted
, libredirect
}: }:
buildPythonPackage rec { buildPythonPackage rec {
pname = "cassandra-driver"; pname = "cassandra-driver";
version = "3.24.0"; version = "3.24.0";
src = fetchPypi { # pypi tarball doesn't include tests
inherit pname version; src = fetchFromGitHub {
sha256 = "83ec8d9a5827ee44bb1c0601a63696a8a9086beaf0151c8255556299246081bd"; owner = "datastax";
repo = "python-driver";
rev = version;
sha256 = "1rr69hly5q810xpn8rkzxwzlq55wxxp7kwki9vfri3gh674d2wip";
}; };
nativeBuildInputs = [ cython ]; nativeBuildInputs = [ cython ];
buildInputs = [ libev ]; buildInputs = [ libev ];
propagatedBuildInputs = [ six ] propagatedBuildInputs = [ six geomet ]
++ lib.optionals (pythonOlder "3.4") [ futures ]; ++ lib.optionals (pythonOlder "3.4") [ futures ];
checkInputs = [ eventlet mock nose pytest pytz pyyaml sure ]; # Make /etc/protocols accessible to allow socket.getprotobyname('tcp') in sandbox,
# also /etc/resolv.conf is referenced by some tests
# ignore test files which try to do socket.getprotocolname('tcp') preCheck = (stdenv.lib.optionalString stdenv.isLinux ''
# as it fails in sandbox mode due to lack of a /etc/protocols file echo "nameserver 127.0.0.1" > resolv.conf
checkPhase = '' export NIX_REDIRECTS=/etc/protocols=${iana-etc}/etc/protocols:/etc/resolv.conf=$(realpath resolv.conf)
pytest tests/unit \ export LD_PRELOAD=${libredirect}/lib/libredirect.so
--ignore=tests/unit/io/test_libevreactor.py \ '') + ''
--ignore=tests/unit/io/test_eventletreactor.py \ # increase tolerance for time-based test
--ignore=tests/unit/io/test_asyncorereactor.py substituteInPlace tests/unit/io/utils.py --replace 'delta=.15' 'delta=.3'
''; '';
postCheck = ''
unset NIX_REDIRECTS LD_PRELOAD
'';
checkInputs = [
pytestCheckHook
eventlet
mock
nose
pytz
pyyaml
sure
scales
gremlinpython
gevent
twisted
];
pytestFlagsArray = [
"tests/unit"
# requires puresasl
"--ignore=tests/unit/advanced/test_auth.py"
];
disabledTests = [
# doesn't seem to be intended to be run directly
"_PoolTests"
# attempts to make connection to localhost
"test_connection_initialization"
];
meta = with lib; { meta = with lib; {
description = "A Python client driver for Apache Cassandra"; description = "A Python client driver for Apache Cassandra";
homepage = "http://datastax.github.io/python-driver"; homepage = "http://datastax.github.io/python-driver";
license = licenses.asl20; license = licenses.asl20;
broken = true; # geomet doesn't exist maintainers = with maintainers; [ turion ris ];
}; };
} }