From e465c840f58e60df51f2d9608dccc1966babf0c8 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Wed, 8 Apr 2020 16:24:35 +1200 Subject: [PATCH] Avoid calling builtins.head on potentially-empty list When no matching wheels are found, builtins.head causes this to fail with a very low-level error. Better to return an empty list and trigger the assertion in the code which calls this. --- pep425.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pep425.nix b/pep425.nix index cda4e8c..6b63146 100644 --- a/pep425.nix +++ b/pep425.nix @@ -87,8 +87,8 @@ let let osxMatches = [ "10_12" "10_11" "10_10" "10_9" "any" ]; linuxMatches = [ "manylinux1_" "manylinux2010_" "manylinux2014_" "any" ]; - chooseLinux = x: lib.singleton (builtins.head (findBestMatches linuxMatches x)); - chooseOSX = x: lib.singleton (builtins.head (findBestMatches osxMatches x)); + chooseLinux = x: lib.take 1 (findBestMatches linuxMatches x); + chooseOSX = x: lib.take 1 (findBestMatches osxMatches x); in if isLinux then chooseLinux files