1
0
Fork 0
mirror of https://code.forgejo.org/actions/setup-python synced 2025-06-08 12:28:20 +02: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(installDir);
core.addPath(_binDir); core.addPath(_binDir);
if (utils_1.IS_WINDOWS) { if (utils_1.IS_WINDOWS) {
// Add --user directory
const version = path.basename(path.dirname(installDir)); const version = path.basename(path.dirname(installDir));
const major = semver.major(version); const major = semver.major(version);
const minor = semver.minor(version); const minor = semver.minor(version);
if (major > 3 || (major === 3 && minor >= 10)) { if (architecture === 'x86' &&
// Handle Python >= 3.10 (major > 3 || (major === 3 && minor >= 10))) {
const isFreeThreaded = core.getBooleanInput('freethreaded'); // For Python >= 3.10 and architecture='x86', add the architecture-specific folder to the path
const arch = architecture === 'x86' ? '-32' : ''; const arch = '32'; // Only for x86 architecture
const baseName = `Python${major}${minor}${isFreeThreaded ? 't' : ''}${arch}`; const userScriptsDir = path.join(process.env['APPDATA'] || '', 'Python', `Python${major}${minor}-${arch}`, 'Scripts');
const pythonPath = path.join(process.env['APPDATA'] || '', 'Python', baseName, 'Scripts'); core.addPath(userScriptsDir);
core.addPath(pythonPath);
} }
else { else {
// Handle Python < 3.10 // For Python >= 3.10 and architecture 'x64', or other versions, use the default user path
const isFreeThreaded = core.getBooleanInput('freethreaded'); const userScriptsDir = path.join(process.env['APPDATA'] || '', 'Python', `Python${major}${minor}`, 'Scripts');
const suffix = isFreeThreaded ? 't' : ''; core.addPath(userScriptsDir);
const baseName = `Python${major}${minor}${suffix}`;
const pythonPath = path.join(process.env['APPDATA'] || '', 'Python', baseName, '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. // 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); core.addPath(_binDir);
if (IS_WINDOWS) { if (IS_WINDOWS) {
// Add --user directory
const version = path.basename(path.dirname(installDir)); const version = path.basename(path.dirname(installDir));
const major = semver.major(version); const major = semver.major(version);
const minor = semver.minor(version); const minor = semver.minor(version);
if (major > 3 || (major === 3 && minor >= 10)) { if (
// Handle Python >= 3.10 architecture === 'x86' &&
const isFreeThreaded = core.getBooleanInput('freethreaded'); (major > 3 || (major === 3 && minor >= 10))
const arch = architecture === 'x86' ? '-32' : ''; ) {
// 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}${ const userScriptsDir = path.join(
isFreeThreaded ? 't' : ''
}${arch}`;
const pythonPath = path.join(
process.env['APPDATA'] || '', process.env['APPDATA'] || '',
'Python', 'Python',
baseName, `Python${major}${minor}-${arch}`,
'Scripts' 'Scripts'
); );
core.addPath(userScriptsDir);
core.addPath(pythonPath);
} else { } else {
// Handle Python < 3.10 // For Python >= 3.10 and architecture 'x64', or other versions, use the default user path
const isFreeThreaded = core.getBooleanInput('freethreaded'); const userScriptsDir = path.join(
const suffix = isFreeThreaded ? 't' : '';
const baseName = `Python${major}${minor}${suffix}`;
const pythonPath = path.join(
process.env['APPDATA'] || '', process.env['APPDATA'] || '',
'Python', 'Python',
baseName, `Python${major}${minor}`,
'Scripts' '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);
} }
// On Linux and macOS, pip will create the --user directory and add it to PATH as needed. // On Linux and macOS, pip will create the --user directory and add it to PATH as needed.
} }