1
0
Fork 0
mirror of https://github.com/actions/setup-python.git synced 2025-04-08 17:18:38 +00:00
This commit is contained in:
aparnajyothi-y 2025-03-25 05:35:36 +00:00 committed by GitHub
commit e526677d05
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 77 additions and 13 deletions

30
dist/setup/index.js vendored
View file

@ -96884,13 +96884,35 @@ 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/<semantic version>/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);
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'; // Only for x86 architecture
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 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);
}
}
// On Linux and macOS, pip will create the --user directory and add it to PATH as needed.
}

View file

@ -153,19 +153,61 @@ export async function useCpythonVersion(
if (IS_WINDOWS) {
// Add --user directory
// `installDir` from tool cache should look like $RUNNER_TOOL_CACHE/Python/<semantic version>/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);
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'; // Only for x86 architecture
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 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);
}
}
// On Linux and macOS, pip will create the --user directory and add it to PATH as needed.
}