mirror of
https://code.forgejo.org/actions/setup-python
synced 2025-06-08 12:28:20 +02:00
update the logic
This commit is contained in:
parent
c614f62548
commit
404bd3b57d
2 changed files with 25 additions and 41 deletions
24
dist/setup/index.js
vendored
24
dist/setup/index.js
vendored
|
@ -96883,26 +96883,24 @@ 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
|
// Extract version details
|
||||||
// `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`// 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);
|
||||||
|
const basePath = process.env['APPDATA'] || '';
|
||||||
|
let versionSuffix = `${major}${minor}`;
|
||||||
|
// Append '-32' for x86 architecture if Python version is >= 3.10
|
||||||
if (architecture === 'x86' &&
|
if (architecture === 'x86' &&
|
||||||
(major > 3 || (major === 3 && minor >= 10))) {
|
(major > 3 || (major === 3 && minor >= 10))) {
|
||||||
// For Python >= 3.10 and architecture='x86', add the architecture-specific folder to the path
|
versionSuffix += '-32';
|
||||||
const arch = '32'; // Only for x86 architecture
|
|
||||||
const userScriptsDir = path.join(process.env['APPDATA'] || '', 'Python', `Python${major}${minor}-${arch}`, 'Scripts');
|
|
||||||
core.addPath(userScriptsDir);
|
|
||||||
}
|
}
|
||||||
else {
|
// Append 't' for freethreaded builds
|
||||||
const userScriptsDir = path.join(process.env['APPDATA'] || '', 'Python', `Python${major}${minor}`, 'Scripts');
|
if (freethreaded) {
|
||||||
core.addPath(userScriptsDir);
|
versionSuffix += 't';
|
||||||
}
|
}
|
||||||
// for free-freethreaded versions, add the freethreaded scripts directory
|
// Add user Scripts path
|
||||||
const pythonPath = path.join(process.env['APPDATA'] || '', 'Python', `Python${major}${minor}t`, 'Scripts');
|
const userScriptsDir = path.join(basePath, 'Python', `Python${versionSuffix}`, 'Scripts');
|
||||||
core.addPath(pythonPath);
|
core.addPath(userScriptsDir);
|
||||||
}
|
}
|
||||||
// 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.
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,45 +152,31 @@ export async function useCpythonVersion(
|
||||||
core.addPath(_binDir);
|
core.addPath(_binDir);
|
||||||
|
|
||||||
if (IS_WINDOWS) {
|
if (IS_WINDOWS) {
|
||||||
// Add --user directory
|
// Extract version details
|
||||||
// `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`// 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);
|
||||||
|
const basePath = process.env['APPDATA'] || '';
|
||||||
|
let versionSuffix = `${major}${minor}`;
|
||||||
|
// Append '-32' for x86 architecture if Python version is >= 3.10
|
||||||
if (
|
if (
|
||||||
architecture === 'x86' &&
|
architecture === 'x86' &&
|
||||||
(major > 3 || (major === 3 && minor >= 10))
|
(major > 3 || (major === 3 && minor >= 10))
|
||||||
) {
|
) {
|
||||||
// For Python >= 3.10 and architecture='x86', add the architecture-specific folder to the path
|
versionSuffix += '-32';
|
||||||
const arch = '32'; // Only for x86 architecture
|
|
||||||
|
|
||||||
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'
|
|
||||||
);
|
|
||||||
core.addPath(userScriptsDir);
|
|
||||||
}
|
}
|
||||||
|
// Append 't' for freethreaded builds
|
||||||
// for free-freethreaded versions, add the freethreaded scripts directory
|
if (freethreaded) {
|
||||||
const pythonPath = path.join(
|
versionSuffix += 't';
|
||||||
process.env['APPDATA'] || '',
|
}
|
||||||
|
// Add user Scripts path
|
||||||
|
const userScriptsDir = path.join(
|
||||||
|
basePath,
|
||||||
'Python',
|
'Python',
|
||||||
`Python${major}${minor}t`,
|
`Python${versionSuffix}`,
|
||||||
'Scripts'
|
'Scripts'
|
||||||
);
|
);
|
||||||
core.addPath(pythonPath);
|
core.addPath(userScriptsDir);
|
||||||
}
|
}
|
||||||
// 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.
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue