python3Packages.paddlepaddle: improve src eval error

Before the change eval raised an unrecoverable failure due to missing
attribute dereference:

    nix-repl> python3Packages.paddlepaddle.src
    error:
       … while evaluating the attribute 'paddlepaddle.src'

       error: attribute 'cp311' missing

       at pkgs/development/python-modules/paddlepaddle/default.nix:33:10:

           32|   allHashAndPlatform = import ./binary-hashes.nix;
           33|   hash = allHashAndPlatform."${stdenv.system}"."${cpuOrGpu}"."${pyShortVersion}"
             |          ^
           34|     ; #or (throw "${pname} has no binary-hashes.nix entry for '${stdenv.system}.${cpuOrGpu}.${pyShortVersion}' attribute");
       Did you mean one of cp310 or cp39?

After the change the error is raised via catchable `throw`:

    nix-repl> python3Packages.paddlepaddle.src
    error:
       … while evaluating the attribute 'paddlepaddle.src'
       error: paddlepaddle has no binary-hashes.nix entry for 'x86_64-linux.cpu.cp311' attribute

This allows for slightly easier scan for syntactic errors over
`nixpkgs`.
This commit is contained in:
Sergei Trofimovich
2024-01-03 17:37:33 +00:00
parent 97f2135e6a
commit 9f2d6c03f5
@@ -28,8 +28,10 @@ let
version = "2.5.0";
format = "wheel";
pyShortVersion = "cp${builtins.replaceStrings ["."] [""] python.pythonVersion}";
cpuOrGpu = if cudaSupport then "gpu" else "cpu";
allHashAndPlatform = import ./binary-hashes.nix;
hash = allHashAndPlatform."${stdenv.system}"."${if cudaSupport then "gpu" else "cpu"}"."${pyShortVersion}";
hash = allHashAndPlatform."${stdenv.system}"."${cpuOrGpu}"."${pyShortVersion}"
or (throw "${pname} has no binary-hashes.nix entry for '${stdenv.system}.${cpuOrGpu}.${pyShortVersion}' attribute");
platform = allHashAndPlatform."${stdenv.system}".platform;
src = fetchPypi ({
inherit version format hash platform;