1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6 fetchpatch,
7 pythonOlder,
8 isPyPy,
9
10 # build-system
11 poetry-core,
12 rustPlatform,
13
14 # native dependencies
15 iconv,
16
17 # dependencies
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.1.0";
31 pyproject = true;
32
33 src = fetchFromGitHub {
34 owner = "sdispater";
35 repo = "pendulum";
36 tag = version;
37 hash = "sha256-ZjQaN5vT1+3UxwLNNsUmU4gSs6reUl90VSEumS0sEGY=";
38 };
39
40 cargoRoot = "rust";
41 cargoDeps = rustPlatform.fetchCargoVendor {
42 inherit pname version src;
43 sourceRoot = "${src.name}/rust";
44 hash = "sha256-F5bCuvI8DcyeUTS7UyYBixCjuGFKGOXPw8HLVlYKuxA=";
45 };
46
47 nativeBuildInputs = [
48 poetry-core
49 rustPlatform.maturinBuildHook
50 rustPlatform.cargoSetupHook
51 ];
52
53 buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ iconv ];
54
55 propagatedBuildInputs = [
56 python-dateutil
57 tzdata
58 ]
59 ++ lib.optional (!isPyPy) [ time-machine ]
60 ++ lib.optionals (pythonOlder "3.9") [
61 importlib-resources
62 ];
63
64 pythonImportsCheck = [ "pendulum" ];
65
66 nativeCheckInputs = [
67 pytestCheckHook
68 pytz
69 ];
70
71 disabledTestPaths = [
72 "tests/benchmarks"
73 ]
74 ++ lib.optionals stdenv.hostPlatform.isDarwin [
75 # PermissionError: [Errno 1] Operation not permitted: '/etc/localtime'
76 "tests/testing/test_time_travel.py"
77 ];
78
79 meta = with lib; {
80 description = "Python datetimes made easy";
81 homepage = "https://github.com/sdispater/pendulum";
82 changelog = "https://github.com/sdispater/pendulum/blob/${src.rev}/CHANGELOG.md";
83 license = licenses.mit;
84 maintainers = [ ];
85 };
86}