1
0
Fork 0
mirror of https://github.com/actions/setup-python.git synced 2025-06-08 06:27:00 +09:00

code update for free threaded

This commit is contained in:
Aparna Jyothi 2025-04-28 15:49:13 +05:30
parent 68111ac40e
commit 114b4684b8
2 changed files with 36 additions and 34 deletions

26
dist/setup/index.js vendored
View file

@ -96883,25 +96883,25 @@ function useCpythonVersion(version, architecture, updateEnvironment, checkLatest
core.addPath(installDir);
core.addPath(_binDir);
if (utils_1.IS_WINDOWS) {
// Add --user directory
const version = path.basename(path.dirname(installDir));
const major = semver.major(version);
const minor = semver.minor(version);
if (major > 3 || (major === 3 && minor >= 10)) {
// Handle Python >= 3.10
const isFreeThreaded = core.getBooleanInput('freethreaded');
const arch = architecture === 'x86' ? '-32' : '';
const baseName = `Python${major}${minor}${isFreeThreaded ? 't' : ''}${arch}`;
const pythonPath = path.join(process.env['APPDATA'] || '', 'Python', baseName, '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
const userScriptsDir = path.join(process.env['APPDATA'] || '', 'Python', `Python${major}${minor}-${arch}`, 'Scripts');
core.addPath(userScriptsDir);
}
else {
// Handle Python < 3.10
const isFreeThreaded = core.getBooleanInput('freethreaded');
const suffix = isFreeThreaded ? 't' : '';
const baseName = `Python${major}${minor}${suffix}`;
const pythonPath = path.join(process.env['APPDATA'] || '', 'Python', baseName, 'Scripts');
core.addPath(pythonPath);
// 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);
}
// 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

@ -152,42 +152,44 @@ export async function useCpythonVersion(
core.addPath(_binDir);
if (IS_WINDOWS) {
// Add --user directory
const version = path.basename(path.dirname(installDir));
const major = semver.major(version);
const minor = semver.minor(version);
if (major > 3 || (major === 3 && minor >= 10)) {
// Handle Python >= 3.10
const isFreeThreaded = core.getBooleanInput('freethreaded');
const arch = architecture === 'x86' ? '-32' : '';
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 baseName = `Python${major}${minor}${
isFreeThreaded ? 't' : ''
}${arch}`;
const pythonPath = path.join(
const userScriptsDir = path.join(
process.env['APPDATA'] || '',
'Python',
baseName,
`Python${major}${minor}-${arch}`,
'Scripts'
);
core.addPath(pythonPath);
core.addPath(userScriptsDir);
} else {
// Handle Python < 3.10
const isFreeThreaded = core.getBooleanInput('freethreaded');
const suffix = isFreeThreaded ? 't' : '';
const baseName = `Python${major}${minor}${suffix}`;
const pythonPath = path.join(
// For Python >= 3.10 and architecture 'x64', or other versions, use the default user path
const userScriptsDir = path.join(
process.env['APPDATA'] || '',
'Python',
baseName,
`Python${major}${minor}`,
'Scripts'
);
core.addPath(pythonPath);
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.
}