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