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