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.
This commit is contained in:
Steve Purcell 2020-04-08 16:24:35 +12:00
parent b7b50f4098
commit e465c840f5

View file

@ -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