about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/python-modules/pendulum/default.nix
blob: 78e9c675ea8db746942fa658f10bca51c25efc7e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
{ lib
, stdenv
, buildPythonPackage
, fetchFromGitHub
, pythonOlder
, isPyPy

# build-system
, poetry-core
, rustPlatform

# native dependencies
, iconv

# dependencies
, backports-zoneinfo
, importlib-resources
, python-dateutil
, time-machine
, tzdata

# tests
, pytestCheckHook
, pytz
}:

buildPythonPackage rec {
  pname = "pendulum";
  version = "3.0.0";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "sdispater";
    repo = "pendulum";
    rev = "refs/tags/${version}";
    hash = "sha256-v0kp8dklvDeC7zdTDOpIbpuj13aGub+oCaYz2ytkEpI=";
  };

  postPatch = ''
    substituteInPlace rust/Cargo.lock \
      --replace "3.0.0-beta-1" "3.0.0"
  '';

  cargoRoot = "rust";
  cargoDeps = rustPlatform.fetchCargoTarball {
    inherit src;
    sourceRoot = "source/rust";
    name = "${pname}-${version}";
    hash = "sha256-6fw0KgnPIMfdseWcunsGjvjVB+lJNoG3pLDqkORPJ0I=";
    postPatch = ''
      substituteInPlace Cargo.lock \
        --replace "3.0.0-beta-1" "3.0.0"
    '';
  };

  nativeBuildInputs = [
    poetry-core
    rustPlatform.maturinBuildHook
    rustPlatform.cargoSetupHook
  ];

  buildInputs = lib.optionals stdenv.isDarwin [
    iconv
  ];

  propagatedBuildInputs = [
    python-dateutil
    tzdata
  ] ++ lib.optional (!isPyPy) [
    time-machine
  ] ++ lib.optionals (pythonOlder "3.9") [
    backports-zoneinfo
    importlib-resources
  ];

  pythonImportsCheck = [
    "pendulum"
  ];

  nativeCheckInputs = [
    pytestCheckHook
    pytz
  ];

  disabledTestPaths = [
    "tests/benchmarks"
  ] ++ lib.optionals stdenv.isDarwin [
    # PermissionError: [Errno 1] Operation not permitted: '/etc/localtime'
    "tests/testing/test_time_travel.py"
  ];

  meta = with lib; {
    description = "Python datetimes made easy";
    homepage = "https://github.com/sdispater/pendulum";
    changelog = "https://github.com/sdispater/pendulum/blob/${src.rev}/CHANGELOG.md";
    license = licenses.mit;
    maintainers = with maintainers; [ ];
  };
}