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