1{
2 lib,
3 stdenv,
4 attrs,
5 buildPythonPackage,
6 fetchFromGitHub,
7 fetchpatch,
8 pendulum,
9 poetry-core,
10 pprintpp,
11 pytestCheckHook,
12 pythonOlder,
13 pythonRelaxDepsHook,
14 wrapt,
15}:
16
17buildPythonPackage rec {
18 pname = "tbm-utils";
19 version = "2.6.0";
20 pyproject = true;
21
22 disabled = pythonOlder "3.9";
23
24 src = fetchFromGitHub {
25 owner = "thebigmunch";
26 repo = "tbm-utils";
27 rev = "refs/tags/${version}";
28 hash = "sha256-AEKawsAxDSDNkIaXEFFgdEBOY2PpASDrhlDrsnM5eyA=";
29 };
30
31 patches = [
32 # Migrate to pendulum > 3, https://github.com/thebigmunch/tbm-utils/pull/3
33 (fetchpatch {
34 name = "support-pendulum-3.patch";
35 url = "https://github.com/thebigmunch/tbm-utils/commit/473534fae2d9a8dea9100cead6c54cab3f5cd0cd.patch";
36 hash = "sha256-3T0KhSmO9r1vM67FWEnTZMQV4b5jS2xtPHI0t9NnCmI=";
37 })
38 (fetchpatch {
39 name = "update-testsupport-pendulum-3.patch";
40 url = "https://github.com/thebigmunch/tbm-utils/commit/a0331d0c15f11cd26bfbb42eebd17296167161ed.patch";
41 hash = "sha256-KG6yfnnBltavbNvIBTdbK+CPXwZTLYl14925RY2a8vs=";
42 })
43 ];
44
45 postPatch = ''
46 substituteInPlace pyproject.toml \
47 --replace-fail 'poetry>=1.0.0' 'poetry-core' \
48 --replace-fail 'poetry.masonry.api' 'poetry.core.masonry.api'
49 '';
50
51 pythonRelaxDeps = [ "attrs" ];
52
53 build-system = [ poetry-core ];
54
55 nativeBuildInputs = [ pythonRelaxDepsHook ];
56
57 propagatedBuildInputs = [
58 attrs
59 pendulum
60 pprintpp
61 wrapt
62 ];
63
64 nativeCheckInputs = [ pytestCheckHook ];
65
66 disabledTests = lib.optionals stdenv.isDarwin [
67 # Skip on macOS because /etc/localtime is accessed through the pendulum
68 # library, which is not allowed in a sandboxed build.
69 "test_create_parser_filter_dates"
70 "test_parse_args"
71 ];
72
73 disabledTestPaths = lib.optionals stdenv.isDarwin [
74 # Skip on macOS because /etc/localtime is accessed through the pendulum
75 # library, which is not allowed in a sandboxed build.
76 "tests/test_datetime.py"
77 "tests/test_misc.py"
78 ];
79
80 pythonImportsCheck = [ "tbm_utils" ];
81
82 meta = with lib; {
83 description = "A commonly-used set of utilities";
84 homepage = "https://github.com/thebigmunch/tbm-utils";
85 changelog = "https://github.com/thebigmunch/tbm-utils/blob/${version}/CHANGELOG.md";
86 license = licenses.mit;
87 maintainers = with maintainers; [ ];
88 };
89}