Skip to content
This repository was archived by the owner on Apr 6, 2026. It is now read-only.

Commit f6a2c44

Browse files
authored
Make build-and-upload and kernels work without applicable build set (#344)
We usually want the `build-and-upload` and `kernels` commands to work, even when there are no applicable build sets (e.g. when compiling a CUDA kernel on macOS). This makes it easier to integrate these commands into CI (which would otherwise fail). This change makes it so that these commands work without applicable build sets.
1 parent b16ea2a commit f6a2c44

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

lib/gen-flake-outputs.nix

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,16 @@ let
101101
else
102102
builtins.head buildSetsSorted;
103103
shellTorch = bestBuildSet.torch.variant;
104+
# We need a package set for some outputs (e.g. kernels and build-and-upload),
105+
# even when there is no applicable build set.
106+
pkgs =
107+
let
108+
sorted = lib.sort configCompare (addSortOrder buildSets);
109+
in
110+
if sorted == [ ] then
111+
throw "No build set is available for this system"
112+
else
113+
(builtins.head sorted).pkgs;
104114
headOrEmpty = l: if l == [ ] then [ ] else [ (builtins.head l) ];
105115
in
106116
{
@@ -188,11 +198,17 @@ in
188198
"repo-id"
189199
] "kernels-community/${buildToml.general.name}" buildToml;
190200
branch = lib.attrByPath [ "general" "hub" "branch" ] "main" buildToml;
201+
# `kernels upload` fails when there are no build variants to upload.
202+
# However, we do not want this command to error out in that case, so
203+
# only insert the upload command when there is something to upload.
204+
uploadStr = lib.optionalString (applicableBuildSets != [ ]) ''
205+
${pkgs.python3.pkgs.kernels}/bin/kernels upload --repo-id ${repo_id} --branch ${branch} ${bundle}
206+
'';
191207
in
192208
writeScriptBin "build-and-upload" ''
193209
#!/usr/bin/env bash
194210
set -euo pipefail
195-
${bestBuildSet.pkgs.python3.pkgs.kernels}/bin/kernels upload --repo-id ${repo_id} --branch ${branch} ${bundle}
211+
${uploadStr}
196212
'';
197213

198214
ci =
@@ -214,7 +230,7 @@ in
214230
};
215231

216232
kernels =
217-
bestBuildSet.pkgs.python3.withPackages (
233+
pkgs.python3.withPackages (
218234
ps: with ps; [
219235
kernel-abi-check
220236
kernels

0 commit comments

Comments
 (0)