From 0681a6bff7f9a0a6cc043c5c724f8e8d57728b0e Mon Sep 17 00:00:00 2001 From: Sam Gross Date: Fri, 14 Feb 2025 17:26:31 +0000 Subject: [PATCH] Improve error message when trying to use free threaded Python versions before 3.13 --- dist/setup/index.js | 12 ++++++++---- src/find-python.ts | 24 +++++++++++++++--------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index aada8df6..a1b94a31 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -91073,12 +91073,16 @@ function useCpythonVersion(version, architecture, updateEnvironment, checkLatest } if (!installDir) { const osInfo = yield (0, utils_1.getOSInfo)(); - throw new Error([ + const msg = [ `The version '${version}' with architecture '${architecture}' was not found for ${osInfo ? `${osInfo.osName} ${osInfo.osVersion}` - : 'this operating system'}.`, - `The list of all available versions can be found here: ${installer.MANIFEST_URL}` - ].join(os.EOL)); + : 'this operating system'}.` + ]; + if (freethreaded) { + msg.push(`Free threaded versions are only available for Python 3.13.0 and later.`); + } + msg.push(`The list of all available versions can be found here: ${installer.MANIFEST_URL}`); + throw new Error(msg.join(os.EOL)); } const _binDir = binDir(installDir); const binaryExtension = utils_1.IS_WINDOWS ? '.exe' : ''; diff --git a/src/find-python.ts b/src/find-python.ts index e50ded1f..ddb027cb 100644 --- a/src/find-python.ts +++ b/src/find-python.ts @@ -102,16 +102,22 @@ export async function useCpythonVersion( if (!installDir) { const osInfo = await getOSInfo(); - throw new Error( - [ - `The version '${version}' with architecture '${architecture}' was not found for ${ - osInfo - ? `${osInfo.osName} ${osInfo.osVersion}` - : 'this operating system' - }.`, - `The list of all available versions can be found here: ${installer.MANIFEST_URL}` - ].join(os.EOL) + const msg = [ + `The version '${version}' with architecture '${architecture}' was not found for ${ + osInfo + ? `${osInfo.osName} ${osInfo.osVersion}` + : 'this operating system' + }.` + ]; + if (freethreaded) { + msg.push( + `Free threaded versions are only available for Python 3.13.0 and later.` + ); + } + msg.push( + `The list of all available versions can be found here: ${installer.MANIFEST_URL}` ); + throw new Error(msg.join(os.EOL)); } const _binDir = binDir(installDir);