@@ -788,6 +788,8 @@ def _dist_to_os_names(dist, default_os_names = []):
788
788
"linux-gnu-Fedora27" ,
789
789
"linux-gnu" ,
790
790
"unknown-linux-gnu" ,
791
+ # The ubuntu list could be replaced with _UBUNTU_VERSIONS which
792
+ # spawns more selections and changes a few to neer ubuntu versions.
791
793
"linux-gnu-ubuntu-22.04" ,
792
794
"linux-gnu-ubuntu-20.04" ,
793
795
"linux-gnu-ubuntu-18.04" ,
@@ -810,7 +812,7 @@ def _dist_to_os_names(dist, default_os_names = []):
810
812
] + _UBUNTU_VERSIONS
811
813
return default_os_names
812
814
813
- def _find_llvm_basenames_by_stem (prefixes , is_prefix = False ):
815
+ def _find_llvm_basenames_by_stem (prefixes , * , is_prefix = False , return_first_match = False ):
814
816
basenames = []
815
817
for prefix in prefixes :
816
818
for suffix in [".tar.gz" , ".tar.xz" ]:
@@ -824,6 +826,8 @@ def _find_llvm_basenames_by_stem(prefixes, is_prefix = False):
824
826
continue
825
827
for suffix in [".tar.gz" , ".tar.xz" ]:
826
828
if llvm_dist .endswith (suffix ) and llvm_dist not in basenames :
829
+ if return_first_match :
830
+ return [llvm_dist ]
827
831
basenames .append (llvm_dist )
828
832
return basenames
829
833
@@ -859,7 +863,7 @@ def _find_llvm_basename_list(llvm_version, arch, os, dist):
859
863
os = select_os ,
860
864
)
861
865
for select_os in ["apple-darwin" , "apple-macos" , "darwin-apple" ]
862
- ], True )
866
+ ], is_prefix = True )
863
867
elif os == "windows" :
864
868
return _find_llvm_basenames_by_stem ([
865
869
"clang+llvm-{llvm_version}-{arch}-{os}" .format (
@@ -869,33 +873,27 @@ def _find_llvm_basename_list(llvm_version, arch, os, dist):
869
873
),
870
874
])
871
875
elif dist .name in ["amzn" , "suse" ] and arch == "x86_64" :
872
- names = _find_llvm_basenames_by_stem ([
876
+ return _find_llvm_basenames_by_stem ([
873
877
"clang+llvm-{llvm_version}-{arch}-{os}" .format (
874
878
llvm_version = llvm_version ,
875
879
arch = arch ,
876
880
os = suse_os ,
877
881
)
878
882
for suse_os in _dist_to_os_names (dist )
879
- ], True )
880
- if names :
881
- return [names [0 ]]
882
- return []
883
+ ], is_prefix = True , return_first_match = True )
883
884
elif dist .name in _UBUNTU_NAMES :
884
885
arch_list = {
885
886
"sparcv9" : ["sparc64" , "sparcv9" ],
886
887
}.get (arch , [arch ])
887
- names = _find_llvm_basenames_by_stem ([
888
+ return _find_llvm_basenames_by_stem ([
888
889
"clang+llvm-{llvm_version}-{arch}-{os}" .format (
889
890
llvm_version = llvm_version ,
890
891
arch = select_arch ,
891
892
os = select_os ,
892
893
)
893
894
for select_os in _dist_to_os_names (dist )
894
895
for select_arch in arch_list
895
- ])
896
- if names :
897
- return [names [0 ]]
898
- return []
896
+ ], return_first_match = True )
899
897
elif dist .name == "fedora" and arch not in ["sparc64" , "sparcv9" ]:
900
898
return _find_llvm_basenames_by_stem ([
901
899
"clang+llvm-{llvm_version}-{arch}-{os}" .format (
@@ -956,7 +954,7 @@ def _find_llvm_basename_list(llvm_version, arch, os, dist):
956
954
arch = arch_alias ,
957
955
dist_name = dist_name ,
958
956
))
959
- names = _find_llvm_basenames_by_stem (prefixes , True )
957
+ names = _find_llvm_basenames_by_stem (prefixes , is_prefix = True )
960
958
if names and dist .name == "ubuntu" :
961
959
return [names [- 1 ]]
962
960
return names
0 commit comments