1{
2 lib,
3 buildPythonPackage,
4 fetchPypi,
5
6 # build-system
7 pbr,
8 setuptools,
9
10 # dependencies
11 debtcollector,
12 iso8601,
13 netaddr,
14 netifaces,
15 oslo-i18n,
16 packaging,
17 psutil,
18 pyparsing,
19 pytz,
20 tzdata,
21
22 # tests
23 ddt,
24 eventlet,
25 fixtures,
26 iana-etc,
27 libredirect,
28 libxcrypt-legacy,
29 oslotest,
30 pyyaml,
31 qemu-utils,
32 replaceVars,
33 stdenv,
34 stestr,
35 testscenarios,
36}:
37
38buildPythonPackage rec {
39 pname = "oslo-utils";
40 version = "9.1.0";
41 pyproject = true;
42
43 src = fetchPypi {
44 pname = "oslo_utils";
45 inherit version;
46 hash = "sha256-AcOHXnzKAFtZRlxCn0ZxE7X0sEIRy9U0yawvFSJ207M=";
47 };
48
49 patches = [
50 (replaceVars ./ctypes.patch {
51 crypt = "${lib.getLib libxcrypt-legacy}/lib/libcrypt${stdenv.hostPlatform.extensions.sharedLibrary}";
52 })
53 ];
54
55 postPatch = ''
56 # only a small portion of the listed packages are actually needed for running the tests
57 # so instead of removing them one by one remove everything
58 rm test-requirements.txt
59 '';
60
61 build-system = [
62 pbr
63 setuptools
64 ];
65
66 dependencies = [
67 debtcollector
68 iso8601
69 netaddr
70 netifaces
71 oslo-i18n
72 packaging
73 psutil
74 pyparsing
75 pytz
76 tzdata
77 ];
78
79 nativeCheckInputs = [
80 ddt
81 eventlet
82 fixtures
83 libredirect.hook
84 oslotest
85 pyyaml
86 qemu-utils
87 stestr
88 testscenarios
89 ];
90
91 # disabled tests:
92 # https://bugs.launchpad.net/oslo.utils/+bug/2054134
93 # netaddr default behaviour changed to be stricter
94 checkPhase = ''
95 echo "nameserver 127.0.0.1" > resolv.conf
96 export NIX_REDIRECTS=/etc/protocols=${iana-etc}/etc/protocols:/etc/resolv.conf=$(realpath resolv.conf)
97
98 stestr run -e <(echo "
99 oslo_utils.tests.test_netutils.NetworkUtilsTest.test_is_valid_ip
100 oslo_utils.tests.test_netutils.NetworkUtilsTest.test_is_valid_ipv4
101 oslo_utils.tests.test_eventletutils.EventletUtilsTest.test_event_set_clear_timeout
102 ")
103 '';
104
105 pythonImportsCheck = [ "oslo_utils" ];
106
107 meta = {
108 description = "Oslo Utility library";
109 homepage = "https://github.com/openstack/oslo.utils";
110 license = lib.licenses.asl20;
111 teams = [ lib.teams.openstack ];
112 };
113}