From da4451310f5845d04265284f923710bac33c7a1d Mon Sep 17 00:00:00 2001 From: Aparna Jyothi Date: Tue, 25 Mar 2025 11:05:31 +0530 Subject: [PATCH] update the install path for free-threaded --- dist/setup/index.js | 25 ++++++++++++++++++------- src/find-python.ts | 42 ++++++++++++++++++++++++++++++------------ 2 files changed, 48 insertions(+), 19 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index e4f01e42..cd004c88 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -99613,17 +99613,28 @@ function useCpythonVersion(version, architecture, updateEnvironment, checkLatest (major > 3 || (major === 3 && minor >= 10))) { // For Python >= 3.10 and architecture='x86', add the architecture-specific folder to the path const arch = '32'; // Only for x86 architecture - const userScriptsDir = path.join(process.env['APPDATA'] || '', 'Python', `Python${major}${minor}-${arch}`, 'Scripts'); - core.addPath(userScriptsDir); + const pythonPath = path.join(process.env['APPDATA'] || '', 'Python', `Python${major}${minor}-${arch}`, 'Scripts'); + core.addPath(pythonPath); } else { // For Python >= 3.10 and architecture 'x64', or other versions, use the default user path - const userScriptsDir = path.join(process.env['APPDATA'] || '', 'Python', `Python${major}${minor}`, 'Scripts'); - core.addPath(userScriptsDir); + const pythonPath = path.join(process.env['APPDATA'] || '', 'Python', `Python${major}${minor}`, 'Scripts'); + core.addPath(pythonPath); + } + if (architecture === 'x86' && + (major > 3 || (major === 3 && minor >= 10))) { + // For Python >= 3.10 and architecture='x86', add the architecture-specific folder to the path + const arch = '32'; // Only for x86 architecture + // Dynamically handle case for Python314t + const pythonPath = path.join(process.env['APPDATA'] || '', 'Python', `Python${major}${minor}t--${arch}`, 'Scripts'); + core.addPath(pythonPath); + } + else { + // For Python >= 3.10 and architecture 'x64', or other versions, use the default user path + // Dynamically handle case for Python314t + const pythonPath = path.join(process.env['APPDATA'] || '', 'Python', `Python${major}${minor}t`, 'Scripts'); + core.addPath(pythonPath); } - // Dynamically handle case for Python314t - const pythonPath = path.join(process.env['APPDATA'] || '', 'Python', `Python${major}${minor}t`, 'Scripts'); - core.addPath(pythonPath); } // On Linux and macOS, pip will create the --user directory and add it to PATH as needed. } diff --git a/src/find-python.ts b/src/find-python.ts index c6e578e1..e2f68f4c 100644 --- a/src/find-python.ts +++ b/src/find-python.ts @@ -146,32 +146,50 @@ export async function useCpythonVersion( // For Python >= 3.10 and architecture='x86', add the architecture-specific folder to the path const arch = '32'; // Only for x86 architecture - const userScriptsDir = path.join( + const pythonPath = path.join( process.env['APPDATA'] || '', 'Python', `Python${major}${minor}-${arch}`, 'Scripts' ); - core.addPath(userScriptsDir); + core.addPath(pythonPath); } else { // For Python >= 3.10 and architecture 'x64', or other versions, use the default user path - const userScriptsDir = path.join( + const pythonPath = path.join( process.env['APPDATA'] || '', 'Python', `Python${major}${minor}`, 'Scripts' ); - core.addPath(userScriptsDir); + core.addPath(pythonPath); } - // Dynamically handle case for Python314t - const pythonPath = path.join( - process.env['APPDATA'] || '', - 'Python', - `Python${major}${minor}t`, - 'Scripts' - ); - core.addPath(pythonPath); + if ( + architecture === 'x86' && + (major > 3 || (major === 3 && minor >= 10)) + ) { + // For Python >= 3.10 and architecture='x86', add the architecture-specific folder to the path + const arch = '32'; // Only for x86 architecture + + // Dynamically handle case for Python314t + const pythonPath = path.join( + process.env['APPDATA'] || '', + 'Python', + `Python${major}${minor}t--${arch}`, + 'Scripts' + ); + core.addPath(pythonPath); + } else { + // For Python >= 3.10 and architecture 'x64', or other versions, use the default user path + // Dynamically handle case for Python314t + const pythonPath = path.join( + process.env['APPDATA'] || '', + 'Python', + `Python${major}${minor}t`, + 'Scripts' + ); + core.addPath(pythonPath); + } } // On Linux and macOS, pip will create the --user directory and add it to PATH as needed. }