1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6 pythonOlder,
7 isPyPy,
8
9 # build-system
10 poetry-core,
11 rustPlatform,
12
13 # native dependencies
14 iconv,
15
16 # dependencies
17 importlib-resources,
18 python-dateutil,
19 time-machine,
20 tzdata,
21
22 # tests
23 pytestCheckHook,
24 pytz,
25}:
26
27buildPythonPackage rec {
28 pname = "pendulum";
29 version = "3.0.0";
30 pyproject = true;
31
32 src = fetchFromGitHub {
33 owner = "sdispater";
34 repo = "pendulum";
35 rev = "refs/tags/${version}";
36 hash = "sha256-v0kp8dklvDeC7zdTDOpIbpuj13aGub+oCaYz2ytkEpI=";
37 };
38
39 postPatch = ''
40 substituteInPlace rust/Cargo.lock \
41 --replace "3.0.0-beta-1" "3.0.0"
42 '';
43
44 cargoRoot = "rust";
45 cargoDeps = rustPlatform.fetchCargoTarball {
46 inherit src;
47 sourceRoot = "${src.name}/rust";
48 name = "${pname}-${version}";
49 hash = "sha256-6fw0KgnPIMfdseWcunsGjvjVB+lJNoG3pLDqkORPJ0I=";
50 postPatch = ''
51 substituteInPlace Cargo.lock \
52 --replace "3.0.0-beta-1" "3.0.0"
53 '';
54 };
55
56 nativeBuildInputs = [
57 poetry-core
58 rustPlatform.maturinBuildHook
59 rustPlatform.cargoSetupHook
60 ];
61
62 buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ iconv ];
63
64 propagatedBuildInputs =
65 [
66 python-dateutil
67 tzdata
68 ]
69 ++ lib.optional (!isPyPy) [ time-machine ]
70 ++ lib.optionals (pythonOlder "3.9") [
71 importlib-resources
72 ];
73
74 pythonImportsCheck = [ "pendulum" ];
75
76 nativeCheckInputs = [
77 pytestCheckHook
78 pytz
79 ];
80
81 disabledTestPaths =
82 [ "tests/benchmarks" ]
83 ++ lib.optionals stdenv.hostPlatform.isDarwin [
84 # PermissionError: [Errno 1] Operation not permitted: '/etc/localtime'
85 "tests/testing/test_time_travel.py"
86 ];
87
88 meta = with lib; {
89 description = "Python datetimes made easy";
90 homepage = "https://github.com/sdispater/pendulum";
91 changelog = "https://github.com/sdispater/pendulum/blob/${src.rev}/CHANGELOG.md";
92 license = licenses.mit;
93 maintainers = [ ];
94 };
95}