Files
nixpkgs/pkgs/development/python-modules/pendulum/default.nix
T
Artturin e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00

98 lines
2.0 KiB
Nix

{
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 = "${src.name}/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.hostPlatform.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.hostPlatform.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 = [ ];
};
}