Take only torch from PyTorch's index, and lock its builds with every file's address

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ilker ManapandClaude Opus 5.5 committed 2026-10-04 10:45:55 +02:00
1 parent 12efb7d085
commit fbac1aa664
4 files changed
+102 -25

No files matched your search

+16 -4
View File
@@ -40,6 +40,14 @@ func (f *fakePython) run(ctx context.Context, env []string, name string, args ..
return []byte("uv 0.12.20\n"), nil
case strings.HasSuffix(name, "/uv") && args[0] == "venv":
return nil, os.MkdirAll(filepath.Join(args[len(args)-1], "bin"), 0o755)
case strings.HasSuffix(name, "/uv") && args[0] == "pip" && args[1] == "compile":
// From a pyproject: kept in the record, as the request was.
project, _ := os.ReadFile(args[len(args)-1])
f.pmu.Lock()
f.commands = append(f.commands, "pyproject: "+string(project))
f.pmu.Unlock()
out := args[slices.Index(args, "--output-file")+1]
return nil, os.WriteFile(out, []byte("lock-version = \"1.0\"\n"), 0o644)
case strings.HasSuffix(name, "/uv") && args[0] == "pip" && args[1] == "install":
if f.failPip {
return []byte("error: Hash mismatch for torch\n"), errExit
@@ -220,8 +228,12 @@ func TestAnOlderDriverGetsTheSameVLLMBuiltForCUDA12(t *testing.T) {
// Pinned to the digest GitHub publishes for the wheel.
"vllm @ " + in.DownloadBase + "/vllm-project/vllm/releases/download/v0.30.0/" + wheel + "#sha256=" +
strings.TrimPrefix(gh.digests[wheel], "sha256:"),
"--extra-index-url https://download.pytorch.org/whl/cu129 --index-strategy unsafe-best-match -",
"--require-hashes --no-deps -r",
// The torch packages from PyTorch's index and only those; the lock
// records every file's address.
"--format pylock.toml",
`url = "https://download.pytorch.org/whl/cu129"` + "\nexplicit = true",
`torch = { index = "extra" }`, `torchvision = { index = "extra" }`,
"--require-hashes --no-deps -r " + filepath.Join(in.Root, "vllm", "0.30.0-cu129.partial", pylockName),
// Computing on the card, not only importing.
"/bin/python -c import torch",
} {
@@ -230,8 +242,8 @@ func TestAnOlderDriverGetsTheSameVLLMBuiltForCUDA12(t *testing.T) {
}
}
for _, c := range sys.commands {
if strings.Contains(c, "pip install") && !strings.Contains(c, "download.pytorch.org/whl/cu129") {
t.Errorf("installed without the index its torch comes from: %s", c)
if strings.Contains(c, "unsafe-best-match") || strings.Contains(c, "--extra-index-url") {
t.Errorf("every index offered every package: %s", c)
}
}
}