at 23.11-beta 2.3 kB view raw
1{ lib 2, stdenv 3, buildPythonPackage 4, pythonOlder 5, rustPlatform 6, cmake 7, libiconv 8, fetchFromGitHub 9, typing-extensions 10, jemalloc 11, rust-jemalloc-sys 12, darwin 13}: 14let 15 pname = "polars"; 16 version = "0.19.12"; 17 rootSource = fetchFromGitHub { 18 owner = "pola-rs"; 19 repo = "polars"; 20 rev = "refs/tags/py-${version}"; 21 hash = "sha256-6tn3Q6oZfMjgQ5l5xCFnGimLSDLOjTWCW5uEbi6yFZY="; 22 }; 23 rust-jemalloc-sys' = rust-jemalloc-sys.override { 24 jemalloc = jemalloc.override { 25 disableInitExecTls = true; 26 }; 27 }; 28in 29buildPythonPackage { 30 inherit pname version; 31 format = "pyproject"; 32 disabled = pythonOlder "3.6"; 33 src = rootSource; 34 35 patches = [ 36 # workaround for apparent rustc bug 37 # remove when we're at Rust 1.73 38 # https://github.com/pola-rs/polars/issues/12050 39 ./all_horizontal.patch 40 ]; 41 42 # Cargo.lock file is sometimes behind actual release which throws an error, 43 # thus the `sed` command 44 # Make sure to check that the right substitutions are made when updating the package 45 preBuild = '' 46 cd py-polars 47 #sed -i 's/version = "0.18.0"/version = "${version}"/g' Cargo.lock 48 ''; 49 50 cargoDeps = rustPlatform.importCargoLock { 51 lockFile = ./Cargo.lock; 52 outputHashes = { 53 "jsonpath_lib-0.3.0" = "sha256-NKszYpDGG8VxfZSMbsTlzcMGFHBOUeFojNw4P2wM3qk="; 54 }; 55 }; 56 cargoRoot = "py-polars"; 57 58 # Revisit this whenever package or Rust is upgraded 59 RUSTC_BOOTSTRAP = 1; 60 61 propagatedBuildInputs = lib.optionals (pythonOlder "3.11") [ typing-extensions ]; 62 63 dontUseCmakeConfigure = true; 64 65 nativeBuildInputs = [ 66 # needed for libz-ng-sys 67 # TODO: use pkgs.zlib-ng 68 cmake 69 ] ++ (with rustPlatform; [ 70 cargoSetupHook 71 maturinBuildHook 72 ]); 73 74 buildInputs = [ 75 rust-jemalloc-sys' 76 ] ++ lib.optionals stdenv.isDarwin [ 77 libiconv 78 darwin.apple_sdk.frameworks.Security 79 ]; 80 81 pythonImportsCheck = [ "polars" ]; 82 # nativeCheckInputs = [ 83 # pytestCheckHook 84 # fixtures 85 # graphviz 86 # matplotlib 87 # networkx 88 # numpy 89 # pydot 90 # ]; 91 92 meta = with lib; { 93 description = "Fast multi-threaded DataFrame library in Rust | Python | Node.js "; 94 homepage = "https://github.com/pola-rs/polars"; 95 license = licenses.asl20; 96 maintainers = with maintainers; [ happysalada ]; 97 }; 98}