mirror of
https://github.com/astral-sh/setup-uv.git
synced 2025-11-05 09:26:51 +00:00
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:
16
dist/setup/index.js
generated
vendored
16
dist/setup/index.js
generated
vendored
@@ -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);
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user