Use tar for extracting the uv zip file on Windows too (#660)

Use extractTar() instead of extractZip() which is very slow for some
reason (0.3s vs 10s)

Fixes #659
This commit is contained in:
Christoph Reiter
2025-10-24 16:13:48 +02:00
committed by GitHub
parent 2ddd2b9cb3
commit 29cd2350cd
2 changed files with 25 additions and 8 deletions

16
dist/setup/index.js generated vendored
View File

@@ -129211,12 +129211,20 @@ async function downloadVersion(downloadUrl, artifactName, platform, arch, versio
const downloadPath = await tc.downloadTool(downloadUrl, undefined, githubToken); const downloadPath = await tc.downloadTool(downloadUrl, undefined, githubToken);
await (0, checksum_1.validateChecksum)(checkSum, downloadPath, arch, platform, version); await (0, checksum_1.validateChecksum)(checkSum, downloadPath, arch, platform, version);
let uvDir; let uvDir;
const extension = getExtension(platform);
if (platform === "pc-windows-msvc") { if (platform === "pc-windows-msvc") {
const fullPathWithExtension = `${downloadPath}${extension}`;
await node_fs_1.promises.copyFile(downloadPath, fullPathWithExtension);
uvDir = await tc.extractZip(fullPathWithExtension);
// On windows extracting the zip does not create an intermediate directory // On windows extracting the zip does not create an intermediate directory
try {
// Try tar first as it's much faster, but only bsdtar supports zip files,
// so this my fail if another tar, like gnu tar, ends up being used.
uvDir = await tc.extractTar(downloadPath, undefined, "x");
}
catch (err) {
core.info(`Extracting with tar failed, falling back to zip extraction: ${err.message}`);
const extension = getExtension(platform);
const fullPathWithExtension = `${downloadPath}${extension}`;
await node_fs_1.promises.copyFile(downloadPath, fullPathWithExtension);
uvDir = await tc.extractZip(fullPathWithExtension);
}
} }
else { else {
const extractedDir = await tc.extractTar(downloadPath); const extractedDir = await tc.extractTar(downloadPath);

View File

@@ -108,12 +108,21 @@ async function downloadVersion(
await validateChecksum(checkSum, downloadPath, arch, platform, version); await validateChecksum(checkSum, downloadPath, arch, platform, version);
let uvDir: string; let uvDir: string;
const extension = getExtension(platform);
if (platform === "pc-windows-msvc") { if (platform === "pc-windows-msvc") {
const fullPathWithExtension = `${downloadPath}${extension}`;
await fs.copyFile(downloadPath, fullPathWithExtension);
uvDir = await tc.extractZip(fullPathWithExtension);
// On windows extracting the zip does not create an intermediate directory // On windows extracting the zip does not create an intermediate directory
try {
// Try tar first as it's much faster, but only bsdtar supports zip files,
// so this my fail if another tar, like gnu tar, ends up being used.
uvDir = await tc.extractTar(downloadPath, undefined, "x");
} catch (err) {
core.info(
`Extracting with tar failed, falling back to zip extraction: ${(err as Error).message}`,
);
const extension = getExtension(platform);
const fullPathWithExtension = `${downloadPath}${extension}`;
await fs.copyFile(downloadPath, fullPathWithExtension);
uvDir = await tc.extractZip(fullPathWithExtension);
}
} else { } else {
const extractedDir = await tc.extractTar(downloadPath); const extractedDir = await tc.extractTar(downloadPath);
uvDir = path.join(extractedDir, artifactName); uvDir = path.join(extractedDir, artifactName);