1{ lib
2, stdenv
3, buildPythonPackage
4, isPyPy
5, fetchPypi
6, fetchpatch
7, pythonOlder
8, curl
9, openssl
10, bottle
11, pytestCheckHook
12, flaky
13}:
14
15buildPythonPackage rec {
16 pname = "pycurl";
17 version = "7.45.1";
18 disabled = isPyPy || (pythonOlder "3.5"); # https://github.com/pycurl/pycurl/issues/208
19
20 src = fetchPypi {
21 inherit pname version;
22 hash = "sha256-qGOtGP9Hj1VFkkBXiHza5CLhsnRuQWdGFfaHSY6luIo=";
23 };
24
25 patches = [
26 # Pull upstream patch for curl-3.83:
27 # https://github.com/pycurl/pycurl/pull/753
28 (fetchpatch {
29 name = "curl-3.83.patch";
30 url = "https://github.com/pycurl/pycurl/commit/d47c68b1364f8a1a45ab8c584c291d44b762f7b1.patch";
31 hash = "sha256-/lGq7O7ZyytzBAxWJPigcWdvypM7OHLBcp9ItmX7z1g=";
32 })
33 ];
34
35 preConfigure = ''
36 substituteInPlace setup.py --replace '--static-libs' '--libs'
37 export PYCURL_SSL_LIBRARY=openssl
38 '';
39
40 buildInputs = [
41 curl
42 openssl
43 ];
44
45 nativeBuildInputs = [
46 curl
47 ];
48
49 nativeCheckInputs = [
50 bottle
51 pytestCheckHook
52 flaky
53 ];
54
55 pytestFlagsArray = [
56 # don't pick up the tests directory below examples/
57 "tests"
58 ];
59
60 preCheck = ''
61 export HOME=$TMPDIR
62 '';
63
64 disabledTests = [
65 # tests that require network access
66 "test_keyfunction"
67 "test_keyfunction_bogus_return"
68 # OSError: tests/fake-curl/libcurl/with_openssl.so: cannot open shared object file: No such file or directory
69 "test_libcurl_ssl_openssl"
70 # OSError: tests/fake-curl/libcurl/with_nss.so: cannot open shared object file: No such file or directory
71 "test_libcurl_ssl_nss"
72 # OSError: tests/fake-curl/libcurl/with_gnutls.so: cannot open shared object file: No such file or directory
73 "test_libcurl_ssl_gnutls"
74 # AssertionError: assert 'crypto' in ['curl']
75 "test_ssl_in_static_libs"
76 ] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
77 # Fatal Python error: Segmentation fault
78 "cadata_test"
79 ];
80
81 meta = with lib; {
82 homepage = "http://pycurl.io/";
83 description = "Python Interface To The cURL library";
84 license = with licenses; [ lgpl2Only mit ];
85 maintainers = with maintainers; [ SuperSandro2000 ];
86 };
87}