@@ -66511,27 +66511,45 @@ function installPyPy(pypyVersion, pythonVersion, architecture, releases) {
6651166511 const { foundAsset, resolvedPythonVersion, resolvedPyPyVersion } = releaseData;
6651266512 let downloadUrl = `${foundAsset.download_url}`;
6651366513 core.info(`Downloading PyPy from "${downloadUrl}" ...`);
66514- const pypyPath = yield tc.downloadTool(downloadUrl);
66515- core.info('Extracting downloaded archive...');
66516- if (utils_1.IS_WINDOWS) {
66517- downloadDir = yield tc.extractZip(pypyPath);
66514+ try {
66515+ const pypyPath = yield tc.downloadTool(downloadUrl);
66516+ core.info('Extracting downloaded archive...');
66517+ if (utils_1.IS_WINDOWS) {
66518+ downloadDir = yield tc.extractZip(pypyPath);
66519+ }
66520+ else {
66521+ downloadDir = yield tc.extractTar(pypyPath, undefined, 'x');
66522+ }
66523+ // root folder in archive can have unpredictable name so just take the first folder
66524+ // downloadDir is unique folder under TEMP and can't contain any other folders
66525+ const archiveName = fs_1.default.readdirSync(downloadDir)[0];
66526+ const toolDir = path.join(downloadDir, archiveName);
66527+ let installDir = toolDir;
66528+ if (!utils_1.isNightlyKeyword(resolvedPyPyVersion)) {
66529+ installDir = yield tc.cacheDir(toolDir, 'PyPy', resolvedPythonVersion, architecture);
66530+ }
66531+ utils_1.writeExactPyPyVersionFile(installDir, resolvedPyPyVersion);
66532+ const binaryPath = getPyPyBinaryPath(installDir);
66533+ yield createPyPySymlink(binaryPath, resolvedPythonVersion);
66534+ yield installPip(binaryPath);
66535+ return { installDir, resolvedPythonVersion, resolvedPyPyVersion };
66536+ }
66537+ catch (err) {
66538+ if (err instanceof Error) {
66539+ // Rate limit?
66540+ if (err instanceof tc.HTTPError &&
66541+ (err.httpStatusCode === 403 || err.httpStatusCode === 429)) {
66542+ core.info(`Received HTTP status code ${err.httpStatusCode}. This usually indicates the rate limit has been exceeded`);
66543+ }
66544+ else {
66545+ core.info(err.message);
66546+ }
66547+ if (err.stack !== undefined) {
66548+ core.debug(err.stack);
66549+ }
66550+ }
66551+ throw err;
6651866552 }
66519- else {
66520- downloadDir = yield tc.extractTar(pypyPath, undefined, 'x');
66521- }
66522- // root folder in archive can have unpredictable name so just take the first folder
66523- // downloadDir is unique folder under TEMP and can't contain any other folders
66524- const archiveName = fs_1.default.readdirSync(downloadDir)[0];
66525- const toolDir = path.join(downloadDir, archiveName);
66526- let installDir = toolDir;
66527- if (!utils_1.isNightlyKeyword(resolvedPyPyVersion)) {
66528- installDir = yield tc.cacheDir(toolDir, 'PyPy', resolvedPythonVersion, architecture);
66529- }
66530- utils_1.writeExactPyPyVersionFile(installDir, resolvedPyPyVersion);
66531- const binaryPath = getPyPyBinaryPath(installDir);
66532- yield createPyPySymlink(binaryPath, resolvedPythonVersion);
66533- yield installPip(binaryPath);
66534- return { installDir, resolvedPythonVersion, resolvedPyPyVersion };
6653566553 });
6653666554}
6653766555exports.installPyPy = installPyPy;
@@ -66730,17 +66748,35 @@ function installCpythonFromRelease(release) {
6673066748 return __awaiter(this, void 0, void 0, function* () {
6673166749 const downloadUrl = release.files[0].download_url;
6673266750 core.info(`Download from "${downloadUrl}"`);
66733- const pythonPath = yield tc.downloadTool(downloadUrl, undefined, AUTH);
66734- core.info('Extract downloaded archive');
66735- let pythonExtractedFolder;
66736- if (utils_1.IS_WINDOWS) {
66737- pythonExtractedFolder = yield tc.extractZip(pythonPath);
66751+ let pythonPath = '';
66752+ try {
66753+ pythonPath = yield tc.downloadTool(downloadUrl, undefined, AUTH);
66754+ core.info('Extract downloaded archive');
66755+ let pythonExtractedFolder;
66756+ if (utils_1.IS_WINDOWS) {
66757+ pythonExtractedFolder = yield tc.extractZip(pythonPath);
66758+ }
66759+ else {
66760+ pythonExtractedFolder = yield tc.extractTar(pythonPath);
66761+ }
66762+ core.info('Execute installation script');
66763+ yield installPython(pythonExtractedFolder);
6673866764 }
66739- else {
66740- pythonExtractedFolder = yield tc.extractTar(pythonPath);
66765+ catch (err) {
66766+ if (err instanceof tc.HTTPError) {
66767+ // Rate limit?
66768+ if (err.httpStatusCode === 403 || err.httpStatusCode === 429) {
66769+ core.info(`Received HTTP status code ${err.httpStatusCode}. This usually indicates the rate limit has been exceeded`);
66770+ }
66771+ else {
66772+ core.info(err.message);
66773+ }
66774+ if (err.stack) {
66775+ core.debug(err.stack);
66776+ }
66777+ }
66778+ throw err;
6674166779 }
66742- core.info('Execute installation script');
66743- yield installPython(pythonExtractedFolder);
6674466780 });
6674566781}
6674666782exports.installCpythonFromRelease = installCpythonFromRelease;
0 commit comments