From 9c3d82c6efce8700fbff1ddf9c644e7360cc4552 Mon Sep 17 00:00:00 2001 From: edef Date: Tue, 31 Oct 2023 11:57:20 +0000 Subject: [PATCH] python3Packages.polars: disable jemalloc initial exec TLS Otherwise, loading the polars native library fails: > python3 -c 'import polars.polars' /nix/store/hncw7v8djk0vm5asy0jcggia0k60dhdv-python3-3.11.5-env/lib/python3.11/site-packages/polars/utils/build_info.py:5: UserWarning: polars binary missing! from polars.utils.polars_version import get_polars_version Traceback (most recent call last): File "", line 1, in ImportError: /nix/store/gsbfr5ar6bki41qwfz6wbrd59z5p9ciw-jemalloc-5.3.0/lib/libjemalloc.so.2: cannot allocate memory in static TLS block Normally, the jemalloc-sys disable_initial_exec_tls Cargo feature covers this, but we override jemalloc with our own. --- pkgs/development/python-modules/polars/default.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkgs/development/python-modules/polars/default.nix b/pkgs/development/python-modules/polars/default.nix index ccd6f2b79ba9..6ee8a3818be3 100644 --- a/pkgs/development/python-modules/polars/default.nix +++ b/pkgs/development/python-modules/polars/default.nix @@ -6,6 +6,7 @@ , libiconv , fetchFromGitHub , typing-extensions +, jemalloc , rust-jemalloc-sys , darwin }: @@ -18,6 +19,11 @@ let rev = "refs/tags/py-${version}"; hash = "sha256-kV30r2wmswpCUmMRaFsCOeRrlTN5/PU0ogaU2JIHq0E="; }; + rust-jemalloc-sys' = rust-jemalloc-sys.override { + jemalloc = jemalloc.override { + disableInitExecTls = true; + }; + }; in buildPythonPackage { inherit pname version; @@ -51,7 +57,7 @@ buildPythonPackage { nativeBuildInputs = with rustPlatform; [ cargoSetupHook maturinBuildHook ]; buildInputs = [ - rust-jemalloc-sys + rust-jemalloc-sys' ] ++ lib.optionals stdenv.isDarwin [ libiconv darwin.apple_sdk.frameworks.Security