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