depot/third_party/nixpkgs/pkgs/development/python-modules/polars/default.nix
Default email 587713944a Project import generated by Copybara.
GitOrigin-RevId: 6143fc5eeb9c4f00163267708e26191d1e918932
2024-04-21 17:54:59 +02:00

101 lines
2.3 KiB
Nix

{ lib
, stdenv
, buildPythonPackage
, pythonOlder
, rustPlatform
, cmake
, libiconv
, fetchFromGitHub
, typing-extensions
, jemalloc
, rust-jemalloc-sys
, darwin
}:
let
pname = "polars";
version = "0.20.15";
rootSource = fetchFromGitHub {
owner = "pola-rs";
repo = "polars";
rev = "refs/tags/py-${version}";
hash = "sha256-N/VIi0s5unYWqlR5Mpaq9cqXl2ccbzWPuOtE2UbmQw8=";
};
rust-jemalloc-sys' = rust-jemalloc-sys.override {
jemalloc = jemalloc.override {
disableInitExecTls = true;
};
};
in
buildPythonPackage {
inherit pname version;
pyproject = true;
disabled = pythonOlder "3.8";
src = rootSource;
# 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;
};
buildAndTestSubdir = "py-polars";
# Revisit this whenever package or Rust is upgraded
RUSTC_BOOTSTRAP = 1;
propagatedBuildInputs = lib.optionals (pythonOlder "3.11") [
typing-extensions
];
# 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" "--features=all" ];
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.isDarwin [
libiconv
darwin.apple_sdk.frameworks.Security
darwin.apple_sdk.frameworks.SystemConfiguration
];
# nativeCheckInputs = [
# pytestCheckHook
# fixtures
# graphviz
# matplotlib
# networkx
# numpy
# pydot
# ];
pythonImportsCheck = [
"polars"
];
meta = with lib; {
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 = licenses.asl20;
maintainers = with maintainers; [ happysalada ];
};
}