From bd89e34f27ff277222b4907d05507663b0921436 Mon Sep 17 00:00:00 2001 From: Aparna Jyothi Date: Wed, 19 Feb 2025 18:42:54 +0530 Subject: [PATCH] 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. }