From bd89e34f27ff277222b4907d05507663b0921436 Mon Sep 17 00:00:00 2001 From: Aparna Jyothi Date: Wed, 19 Feb 2025 18:42:54 +0530 Subject: [PATCH 1/3] update-install path --user flag for x86 for >=3.10 --- dist/setup/index.js | 14 ++++++++++++-- src/find-python.ts | 32 +++++++++++++++++++++++++------- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 53196f67..6161475d 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -99611,8 +99611,18 @@ function useCpythonVersion(version, architecture, updateEnvironment, checkLatest const version = path.basename(path.dirname(installDir)); const major = semver.major(version); const minor = semver.minor(version); - const userScriptsDir = path.join(process.env['APPDATA'] || '', 'Python', `Python${major}${minor}`, 'Scripts'); - core.addPath(userScriptsDir); + 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'; + const userScriptsDir = path.join(process.env['APPDATA'] || '', 'Python', `Python${major}${minor}-${arch}`, 'Scripts'); + core.addPath(userScriptsDir); + } + else { + const userScriptsDir = path.join(process.env['APPDATA'] || '', 'Python', `Python${major}${minor}`, 'Scripts'); + // Add the default path to the environment PATH variable + core.addPath(userScriptsDir); + } } // 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 77278770..7a3704bc 100644 --- a/src/find-python.ts +++ b/src/find-python.ts @@ -141,13 +141,31 @@ export async function useCpythonVersion( const major = semver.major(version); const minor = semver.minor(version); - const userScriptsDir = path.join( - process.env['APPDATA'] || '', - 'Python', - `Python${major}${minor}`, - 'Scripts' - ); - core.addPath(userScriptsDir); + 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'; + + const userScriptsDir = path.join( + process.env['APPDATA'] || '', + 'Python', + `Python${major}${minor}-${arch}`, + 'Scripts' + ); + core.addPath(userScriptsDir); + } else { + const userScriptsDir = path.join( + process.env['APPDATA'] || '', + 'Python', + `Python${major}${minor}`, + 'Scripts' + ); + + // Add the default path to the environment PATH variable + core.addPath(userScriptsDir); + } } // On Linux and macOS, pip will create the --user directory and add it to PATH as needed. } From feb0ff9aba29abe4ac9611070a2edcd59216a0aa Mon Sep 17 00:00:00 2001 From: Aparna Jyothi Date: Tue, 25 Mar 2025 10:39:20 +0530 Subject: [PATCH 2/3] update-install-path-freethreaded --- dist/setup/index.js | 11 ++++++----- src/find-python.ts | 18 ++++++++++++------ 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 6161475d..e4f01e42 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -99606,23 +99606,24 @@ function useCpythonVersion(version, architecture, updateEnvironment, checkLatest core.addPath(_binDir); if (utils_1.IS_WINDOWS) { // Add --user directory - // `installDir` from tool cache should look like $RUNNER_TOOL_CACHE/Python//x64/ - // So if `findLocalTool` succeeded above, we must have a conformant `installDir` const version = path.basename(path.dirname(installDir)); const major = semver.major(version); const minor = semver.minor(version); 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'; + // 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); } 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'); - // Add the default path to the environment PATH variable core.addPath(userScriptsDir); } + // 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 7a3704bc..c6e578e1 100644 --- a/src/find-python.ts +++ b/src/find-python.ts @@ -135,8 +135,6 @@ export async function useCpythonVersion( if (IS_WINDOWS) { // Add --user directory - // `installDir` from tool cache should look like $RUNNER_TOOL_CACHE/Python//x64/ - // So if `findLocalTool` succeeded above, we must have a conformant `installDir` const version = path.basename(path.dirname(installDir)); const major = semver.major(version); const minor = semver.minor(version); @@ -145,8 +143,8 @@ export async function useCpythonVersion( 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'; + // 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'] || '', @@ -156,16 +154,24 @@ export async function useCpythonVersion( ); core.addPath(userScriptsDir); } 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' ); - - // Add the default path to the environment PATH variable core.addPath(userScriptsDir); } + + // 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. } From da4451310f5845d04265284f923710bac33c7a1d Mon Sep 17 00:00:00 2001 From: Aparna Jyothi Date: Tue, 25 Mar 2025 11:05:31 +0530 Subject: [PATCH 3/3] 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. }