nixpkgs/pkgs/development/python-modules/polars/default.nix
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

100 lines
2.2 KiB
Nix

{
lib,
stdenv,
buildPythonPackage,
rustPlatform,
cmake,
libiconv,
fetchFromGitHub,
jemalloc,
rust-jemalloc-sys,
darwin,
}:
let
rust-jemalloc-sys' = rust-jemalloc-sys.override {
jemalloc = jemalloc.override { disableInitExecTls = true; };
};
in
buildPythonPackage rec {
pname = "polars";
version = "1.7.1";
pyproject = true;
src = fetchFromGitHub {
owner = "pola-rs";
repo = "polars";
rev = "refs/tags/py-${version}";
hash = "sha256-vbligrFrCd7BiPV8n1iRIlurPNirJKOiD4/P5qEpirg=";
};
# Cargo.lock file is sometimes behind actual release which throws an error,
# thus the `sed` command
# Make sure to check that the right substitutions are made when updating the package
preBuild = ''
#sed -i 's/version = "0.18.0"/version = "${version}"/g' Cargo.lock
'';
cargoDeps = rustPlatform.importCargoLock {
lockFile = ./Cargo.lock;
outputHashes = {
"numpy-0.21.0" = "sha256-u0Z+6L8pXSPaA3cE1sUpY6sCoaU1clXUcj/avnNzmsw=";
};
};
buildAndTestSubdir = "py-polars";
# Revisit this whenever package or Rust is upgraded
RUSTC_BOOTSTRAP = 1;
# trick taken from the polars repo since there seems to be a problem
# with simd enabled with our stable rust (instead of nightly).
maturinBuildFlags = [
"--no-default-features"
"--all-features"
];
dontUseCmakeConfigure = true;
nativeBuildInputs =
[
# needed for libz-ng-sys
# TODO: use pkgs.zlib-ng
cmake
]
++ (with rustPlatform; [
cargoSetupHook
maturinBuildHook
]);
buildInputs =
[ rust-jemalloc-sys' ]
++ lib.optionals stdenv.hostPlatform.isDarwin [
libiconv
darwin.apple_sdk.frameworks.AppKit
darwin.apple_sdk.frameworks.Security
darwin.apple_sdk.frameworks.SystemConfiguration
];
# nativeCheckInputs = [
# pytestCheckHook
# fixtures
# graphviz
# matplotlib
# networkx
# numpy
# pydot
# ];
pythonImportsCheck = [ "polars" ];
meta = {
description = "Fast multi-threaded DataFrame library";
homepage = "https://github.com/pola-rs/polars";
changelog = "https://github.com/pola-rs/polars/releases/tag/py-${version}";
license = lib.licenses.asl20;
maintainers = with lib.maintainers; [ happysalada ];
};
}