From 1a99974c19d4f094aa207c9f9ab1fc47c1019f47 Mon Sep 17 00:00:00 2001 From: Yuriy Taraday Date: Thu, 3 Jul 2025 17:16:23 +0200 Subject: [PATCH 1/2] tiledb: enable serialization Build headers and libraries required for serialization support. Required for TileDB Python bindings. --- pkgs/by-name/ti/tiledb/package.nix | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/pkgs/by-name/ti/tiledb/package.nix b/pkgs/by-name/ti/tiledb/package.nix index f17e00fba28c..84acdafc39b7 100644 --- a/pkgs/by-name/ti/tiledb/package.nix +++ b/pkgs/by-name/ti/tiledb/package.nix @@ -2,6 +2,7 @@ lib, stdenv, fetchFromGitHub, + fetchpatch, cmake, zlib, lz4, @@ -22,6 +23,8 @@ libpng, file, runCommand, + curl, + capnproto, useAVX2 ? stdenv.hostPlatform.avx2Support, }: @@ -45,7 +48,17 @@ stdenv.mkDerivation rec { hash = "sha256-Cs3Lr8I/Mu02x78d7IySG0XX4u/VAjBs4p4b00XDT5k="; }; - patches = lib.optionals stdenv.hostPlatform.isDarwin [ ./generate_embedded_data_header.patch ]; + patches = [ + # capnproto was updated to 1.2 in Nixpkgs, bring TileDB codebase up to speed + # patch only affects serialization related code, extracted from https://github.com/TileDB-Inc/TileDB/pull/5616 + (fetchpatch { + url = "https://github.com/TileDB-Inc/TileDB/pull/5616.patch"; + relative = "tiledb/sm/serialization"; + extraPrefix = "tiledb/sm/serialization/"; + hash = "sha256-5z/eJEHl+cnWRf1sMULodJyhmNh5KinDLlL1paMNiy4="; + }) + ] + ++ lib.optionals stdenv.hostPlatform.isDarwin [ ./generate_embedded_data_header.patch ]; # libcxx (as of llvm-19) does not yet support `stop_token` and `jthread` # without the -fexperimental-library flag. Tiledb adds its own @@ -62,6 +75,7 @@ stdenv.mkDerivation rec { cmakeFlags = [ "-DTILEDB_WEBP=OFF" "-DTILEDB_WERROR=OFF" + "-DTILEDB_SERIALIZATION=ON" # https://github.com/NixOS/nixpkgs/issues/144170 "-DCMAKE_INSTALL_INCLUDEDIR=include" "-DCMAKE_INSTALL_LIBDIR=lib" @@ -74,6 +88,9 @@ stdenv.mkDerivation rec { cmake python3 doxygen + # Required for serialization + curl + capnproto ] ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames; From 31704383c1c064ea54117ec0409dd99b3901f705 Mon Sep 17 00:00:00 2001 From: Yuriy Taraday Date: Thu, 3 Jul 2025 17:18:18 +0200 Subject: [PATCH 2/2] python3Packages.tiledb: fix build Fix build process: * switch to pyproject * remove unnecessary patching * switch to pytest in tests --- .../python-modules/tiledb/default.nix | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/pkgs/development/python-modules/tiledb/default.nix b/pkgs/development/python-modules/tiledb/default.nix index d43419139032..04383797afb9 100644 --- a/pkgs/development/python-modules/tiledb/default.nix +++ b/pkgs/development/python-modules/tiledb/default.nix @@ -1,5 +1,6 @@ { lib, + stdenv, python, buildPythonPackage, fetchFromGitHub, @@ -12,12 +13,19 @@ setuptools-scm, psutil, pandas, + cmake, + ninja, + scikit-build-core, + packaging, + pytest, + hypothesis, + pyarrow, }: buildPythonPackage rec { pname = "tiledb"; version = "0.34.2"; - format = "setuptools"; + format = "pyproject"; src = fetchFromGitHub { owner = "TileDB-Inc"; @@ -26,58 +34,50 @@ buildPythonPackage rec { hash = "sha256-EXRrWp/2sMn7DCzgXk5L0692rhGtQZwWpVWYnfrxmGA="; }; - nativeBuildInputs = [ + build-system = [ cython pybind11 setuptools-scm + scikit-build-core + packaging + cmake + ninja ]; buildInputs = [ tiledb ]; propagatedBuildInputs = [ numpy - wheel # No idea why but it is listed ]; nativeCheckInputs = [ psutil # optional pandas + pytest + hypothesis + pyarrow ]; TILEDB_PATH = tiledb; disabled = !isPy3k; # Not bothering with python2 anymore - postPatch = '' - # Hardcode path to shared object - substituteInPlace tiledb/__init__.py --replace \ - 'os.path.join(lib_dir, lib_name)' 'os.path.join("${tiledb}/lib", lib_name)' - - # Disable failing test - substituteInPlace tiledb/tests/test_examples.py --replace \ - "test_docs" "dont_test_docs" - # these tests don't always fail - substituteInPlace tiledb/tests/test_libtiledb.py --replace \ - "test_varlen_write_int_subarray" "dont_test_varlen_write_int_subarray" \ - --replace "test_memory_cleanup" "dont_test_memory_cleanup" \ - --replace "test_ctx_thread_cleanup" "dont_test_ctx_thread_cleanup" - substituteInPlace tiledb/tests/test_metadata.py --replace \ - "test_metadata_consecutive" "dont_test_metadata_consecutive" - ''; + dontUseCmakeConfigure = true; + # We have to run pytest from a diffferent directory to force it to import tiledb from $out + # otherwise it cannot be imported because extension modules are not compiled in sources checkPhase = '' pushd "$TMPDIR" - ${python.interpreter} -m unittest tiledb.tests.all.suite_test + ${python.interpreter} -m pytest --pyargs tiledb${lib.optionalString stdenv.isDarwin " -k 'not test_ctx_thread_cleanup and not test_array'"} popd ''; + pythonImportsCheck = [ "tiledb" ]; - meta = with lib; { + meta = { description = "Python interface to the TileDB storage manager"; homepage = "https://github.com/TileDB-Inc/TileDB-Py"; - license = licenses.mit; - # tiledb/core.cc:556:30: error: ‘struct std::array’ has no member named ‘second’ - broken = true; + license = lib.licenses.mit; }; }