From 5a9f5ec038cc3ce924ca45df061aa6a4ce5139a9 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Sat, 10 Jan 2026 09:52:24 +0000 Subject: [PATCH] python3Packages.paddlepaddle: fix evaluation error when selecting unsupported cuda version --- .../python-modules/paddlepaddle/default.nix | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/pkgs/development/python-modules/paddlepaddle/default.nix b/pkgs/development/python-modules/paddlepaddle/default.nix index 96bdf6a76480..fe0f6519409f 100644 --- a/pkgs/development/python-modules/paddlepaddle/default.nix +++ b/pkgs/development/python-modules/paddlepaddle/default.nix @@ -34,21 +34,25 @@ let version = sources.version; format = "wheel"; pyShortVersion = "cp${builtins.replaceStrings [ "." ] [ "" ] python.pythonVersion}"; - hash = - if cudaSupport then - sources."${stdenv.hostPlatform.system}"."gpu"."cu${ - lib.replaceStrings [ "." ] [ "" ] cudaPackages.cudatoolkit.version - }"."${pyShortVersion}" - else - sources."${stdenv.hostPlatform.system}"."cpu"."${pyShortVersion}" - or (throw "Unsupported system: ${stdenv.hostPlatform.system}"); - platform = sources."${stdenv.hostPlatform.system}".platform; + cudaVersion = "cu${lib.replaceStrings [ "." ] [ "" ] cudaPackages.cudatoolkit.version}"; + + throwSystem = throw "Unsupported system: ${stdenv.hostPlatform.system}"; + systemSources = sources."${stdenv.hostPlatform.system}" or throwSystem; + + supportedCudaVersions = lib.concatStringsSep ", " (builtins.attrNames systemSources.gpu); + throwCuda = throw "Unsupported CUDA version: ${cudaVersion}. Supported versions: ${supportedCudaVersions}"; + platformSources = + if cudaSupport then systemSources.gpu.${cudaVersion} or throwCuda else systemSources.cpu; + + throwPython = throw "Unsupported python version: ${pyShortVersion}"; + hash = platformSources.${pyShortVersion} or throwPython; + + platform = sources.${stdenv.hostPlatform.system}.platform; + src = if cudaSupport then (fetchurl { - url = "https://paddle-whl.bj.bcebos.com/stable/cu${ - lib.replaceStrings [ "." ] [ "" ] cudaPackages.cudatoolkit.version - }/paddlepaddle-gpu/paddlepaddle_gpu-${version}-${pyShortVersion}-${pyShortVersion}-linux_x86_64.whl"; + url = "https://paddle-whl.bj.bcebos.com/stable/${cudaVersion}/paddlepaddle-gpu/paddlepaddle_gpu-${version}-${pyShortVersion}-${pyShortVersion}-linux_x86_64.whl"; inherit hash; }) else