1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 dnspython,
6 fetchFromGitHub,
7 fetchpatch,
8 iana-etc,
9 libredirect,
10 pytestCheckHook,
11 pythonOlder,
12 pythonRelaxDepsHook,
13 setuptools,
14}:
15
16buildPythonPackage rec {
17 pname = "ipwhois";
18 version = "1.2.0";
19 pyproject = true;
20
21 disabled = pythonOlder "3.7";
22
23 src = fetchFromGitHub {
24 owner = "secynic";
25 repo = "ipwhois";
26 rev = "refs/tags/v${version}";
27 hash = "sha256-2CfRRHlIIaycUtzKeMBKi6pVPeBCb1nW3/1hoxQU1YM=";
28 };
29
30 patches = [
31 # Use assertEqual instead of assertEquals, https://github.com/secynic/ipwhois/pull/316
32 (fetchpatch {
33 name = "assert-equal.patch";
34 url = "https://github.com/secynic/ipwhois/commit/fce2761354af99bc169e6cd08057e838fcc40f75.patch";
35 hash = "sha256-7Ic4xWTAmklk6MvnZ/WsH9SW/4D9EG/jFKt5Wi89Xtc=";
36 })
37 ];
38
39 __darwinAllowLocalNetworking = true;
40
41 pythonRelaxDeps = [ "dnspython" ];
42
43 nativeBuildInputs = [
44 pythonRelaxDepsHook
45 setuptools
46 ];
47
48 propagatedBuildInputs = [ dnspython ];
49
50 nativeCheckInputs = [ pytestCheckHook ];
51
52 pythonImportsCheck = [ "ipwhois" ];
53
54 preCheck = lib.optionalString stdenv.isLinux ''
55 echo "nameserver 127.0.0.1" > resolv.conf
56 export NIX_REDIRECTS=/etc/protocols=${iana-etc}/etc/protocols:/etc/resolv.conf=$(realpath resolv.conf) \
57 LD_PRELOAD=${libredirect}/lib/libredirect.so
58 '';
59
60 disabledTestPaths = [
61 # Tests require network access
62 "ipwhois/tests/online/"
63 # Stress test
64 "ipwhois/tests/stress/test_experimental.py"
65 ];
66
67 disabledTests = [
68 "test_lookup"
69 "test_unique_addresses"
70 "test_get_http_json"
71 ];
72
73 meta = with lib; {
74 description = "Library to retrieve and parse whois data";
75 homepage = "https://github.com/secynic/ipwhois";
76 changelog = "https://github.com/secynic/ipwhois/blob/v${version}/CHANGES.rst";
77 license = licenses.bsd2;
78 maintainers = with maintainers; [ fab ];
79 };
80}