mirror of
https://code.forgejo.org/actions/setup-python
synced 2025-06-08 12:28:20 +02:00
update the logic for free threaded also
This commit is contained in:
parent
358da85d3a
commit
4260a613f9
2 changed files with 27 additions and 62 deletions
31
dist/setup/index.js
vendored
31
dist/setup/index.js
vendored
|
@ -96883,34 +96883,21 @@ 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 (architecture === 'x86' &&
|
if (major > 3 || (major === 3 && minor >= 10)) {
|
||||||
(major > 3 || (major === 3 && minor >= 10))) {
|
// Handle Python >= 3.10
|
||||||
// For Python >= 3.10 and architecture='x86', add the architecture-specific folder to the path
|
const isFreeThreaded = core.getBooleanInput('freethreaded');
|
||||||
const arch = '32'; // Only for x86 architecture
|
const arch = architecture === 'x86' ? '-32' : '';
|
||||||
const pythonPath = path.join(process.env['APPDATA'] || '', 'Python', `Python${major}${minor}-${arch}`, 'Scripts');
|
const baseName = `Python${major}${minor}${isFreeThreaded ? 't' : ''}${arch}`;
|
||||||
|
const pythonPath = path.join(process.env['APPDATA'] || '', 'Python', baseName, 'Scripts');
|
||||||
core.addPath(pythonPath);
|
core.addPath(pythonPath);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// For Python >= 3.10 and architecture 'x64', or other versions, use the default user path
|
// Handle Python < 3.10
|
||||||
const pythonPath = path.join(process.env['APPDATA'] || '', 'Python', `Python${major}${minor}`, 'Scripts');
|
const baseName = `Python${major}${minor}`;
|
||||||
core.addPath(pythonPath);
|
const pythonPath = path.join(process.env['APPDATA'] || '', 'Python', baseName, 'Scripts');
|
||||||
}
|
|
||||||
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);
|
core.addPath(pythonPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,60 +152,38 @@ 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 (
|
if (major > 3 || (major === 3 && minor >= 10)) {
|
||||||
architecture === 'x86' &&
|
// Handle Python >= 3.10
|
||||||
(major > 3 || (major === 3 && minor >= 10))
|
const isFreeThreaded = core.getBooleanInput('freethreaded');
|
||||||
) {
|
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}${
|
||||||
|
isFreeThreaded ? 't' : ''
|
||||||
|
}${arch}`;
|
||||||
|
|
||||||
const pythonPath = path.join(
|
const pythonPath = path.join(
|
||||||
process.env['APPDATA'] || '',
|
process.env['APPDATA'] || '',
|
||||||
'Python',
|
'Python',
|
||||||
`Python${major}${minor}-${arch}`,
|
baseName,
|
||||||
'Scripts'
|
'Scripts'
|
||||||
);
|
);
|
||||||
|
|
||||||
core.addPath(pythonPath);
|
core.addPath(pythonPath);
|
||||||
} else {
|
} else {
|
||||||
// For Python >= 3.10 and architecture 'x64', or other versions, use the default user path
|
// Handle Python < 3.10
|
||||||
const pythonPath = path.join(
|
const baseName = `Python${major}${minor}`;
|
||||||
process.env['APPDATA'] || '',
|
|
||||||
'Python',
|
|
||||||
`Python${major}${minor}`,
|
|
||||||
'Scripts'
|
|
||||||
);
|
|
||||||
core.addPath(pythonPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
const pythonPath = path.join(
|
||||||
architecture === 'x86' &&
|
process.env['APPDATA'] || '',
|
||||||
(major > 3 || (major === 3 && minor >= 10))
|
'Python',
|
||||||
) {
|
baseName,
|
||||||
// For Python >= 3.10 and architecture='x86', add the architecture-specific folder to the path
|
'Scripts'
|
||||||
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);
|
core.addPath(pythonPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue