From b44e970d8ff6077e199fdb378ec8207aea73b8b9 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Fri, 6 Mar 2026 20:52:23 +0000 Subject: [PATCH] python3Packages.rembg: fix cuda build --- .../python-modules/rembg/default.nix | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/pkgs/development/python-modules/rembg/default.nix b/pkgs/development/python-modules/rembg/default.nix index 209a1df7c07f..4100177c2646 100644 --- a/pkgs/development/python-modules/rembg/default.nix +++ b/pkgs/development/python-modules/rembg/default.nix @@ -33,8 +33,12 @@ # tests versionCheckHook, + pocl, withCli ? false, + config, + cudaSupport ? config.cudaSupport, + writableTmpDirAsHomeHook, }: let @@ -100,9 +104,24 @@ buildPythonPackage (finalAttrs: { postInstall = lib.optionalString (!withCli) "rm -r $out/bin"; # not running python tests, as they require network access - nativeCheckInputs = lib.optionals withCli [ - versionCheckHook - ]; + nativeCheckInputs = + lib.optionals + ( + withCli + # Crashes in the sandbox as no drivers are available + # opencl._cl.RuntimeError: no CL platforms available to ICD loader + && (!cudaSupport) + ) + [ + versionCheckHook + ] + ++ lib.optionals cudaSupport [ + # Provides a CPU-based OpenCL ICD so that pyopencl's module-level + # cl.create_some_context() succeeds without GPU hardware. + pocl + # pocl needs a writable $HOME for its kernel cache directory. + writableTmpDirAsHomeHook + ]; versionCheckKeepEnvironment = [ # Otherwise, fail with: # RuntimeError: cannot cache function '_make_tree': no locator available for file