1{ lib
2, stdenv
3, buildPythonPackage
4, pythonOlder
5, rustPlatform
6, libiconv
7, fetchFromGitHub
8, typing-extensions
9, darwin
10}:
11let
12 pname = "polars";
13 version = "0.18.0"; # Can't update to >0.18.0 until we get rust 1.71
14 rootSource = fetchFromGitHub {
15 owner = "pola-rs";
16 repo = "polars";
17 rev = "refs/tags/py-${version}";
18 hash = "sha256-uzo8KPEegaVuzrfKUmsHheQfmm9hVMgkNJMWdfqDrw8=";
19 };
20in
21buildPythonPackage {
22 inherit pname version;
23 format = "pyproject";
24 disabled = pythonOlder "3.6";
25 src = rootSource;
26
27 # Cargo.lock file is sometimes behind actual release which throws an error,
28 # thus the `sed` command
29 # Make sure to check that the right substitutions are made when updating the package
30 preBuild = ''
31 cd py-polars
32 #sed -i 's/version = "0.18.0"/version = "${version}"/g' Cargo.lock
33 '';
34
35 cargoDeps = rustPlatform.importCargoLock {
36 lockFile = ./Cargo.lock;
37 outputHashes = {
38 "jsonpath_lib-0.3.0" = "sha256-NKszYpDGG8VxfZSMbsTlzcMGFHBOUeFojNw4P2wM3qk=";
39 };
40 };
41 cargoRoot = "py-polars";
42
43 # Revisit this whenever package or Rust is upgraded
44 RUSTC_BOOTSTRAP = 1;
45
46 propagatedBuildInputs = lib.optionals (pythonOlder "3.11") [ typing-extensions ];
47
48 nativeBuildInputs = with rustPlatform; [ cargoSetupHook maturinBuildHook ];
49
50 buildInputs = lib.optionals stdenv.isDarwin [
51 libiconv
52 darwin.apple_sdk.frameworks.Security
53 ];
54
55 pythonImportsCheck = [ "polars" ];
56 # nativeCheckInputs = [
57 # pytestCheckHook
58 # fixtures
59 # graphviz
60 # matplotlib
61 # networkx
62 # numpy
63 # pydot
64 # ];
65
66 meta = with lib; {
67 description = "Fast multi-threaded DataFrame library in Rust | Python | Node.js ";
68 homepage = "https://github.com/pola-rs/polars";
69 license = licenses.asl20;
70 maintainers = with maintainers; [ happysalada ];
71 };
72}