mirror of
https://github.com/actions/setup-python.git
synced 2025-04-17 01:39:13 +08:00
Compare commits
2 commits
bd89e34f27
...
da4451310f
Author | SHA1 | Date | |
---|---|---|---|
|
da4451310f | ||
|
feb0ff9aba |
30
dist/setup/index.js
vendored
30
dist/setup/index.js
vendored
|
@ -99606,22 +99606,34 @@ function useCpythonVersion(version, architecture, updateEnvironment, checkLatest
|
||||||
core.addPath(_binDir);
|
core.addPath(_binDir);
|
||||||
if (utils_1.IS_WINDOWS) {
|
if (utils_1.IS_WINDOWS) {
|
||||||
// Add --user directory
|
// 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 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 (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
|
// For Python >= 3.10 and architecture='x86', add the architecture-specific folder to the path
|
||||||
const arch = '32';
|
const arch = '32'; // Only for x86 architecture
|
||||||
const userScriptsDir = path.join(process.env['APPDATA'] || '', 'Python', `Python${major}${minor}-${arch}`, 'Scripts');
|
const pythonPath = path.join(process.env['APPDATA'] || '', 'Python', `Python${major}${minor}-${arch}`, 'Scripts');
|
||||||
core.addPath(userScriptsDir);
|
core.addPath(pythonPath);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const userScriptsDir = path.join(process.env['APPDATA'] || '', 'Python', `Python${major}${minor}`, 'Scripts');
|
// For Python >= 3.10 and architecture 'x64', or other versions, use the default user path
|
||||||
// Add the default path to the environment PATH variable
|
const pythonPath = path.join(process.env['APPDATA'] || '', 'Python', `Python${major}${minor}`, 'Scripts');
|
||||||
core.addPath(userScriptsDir);
|
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.
|
// On Linux and macOS, pip will create the --user directory and add it to PATH as needed.
|
||||||
|
|
|
@ -135,8 +135,6 @@ export async function useCpythonVersion(
|
||||||
|
|
||||||
if (IS_WINDOWS) {
|
if (IS_WINDOWS) {
|
||||||
// Add --user directory
|
// 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 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);
|
||||||
|
@ -145,26 +143,52 @@ export async function useCpythonVersion(
|
||||||
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
|
// For Python >= 3.10 and architecture='x86', add the architecture-specific folder to the path
|
||||||
const arch = '32';
|
const arch = '32'; // Only for x86 architecture
|
||||||
|
|
||||||
const userScriptsDir = path.join(
|
const pythonPath = path.join(
|
||||||
process.env['APPDATA'] || '',
|
process.env['APPDATA'] || '',
|
||||||
'Python',
|
'Python',
|
||||||
`Python${major}${minor}-${arch}`,
|
`Python${major}${minor}-${arch}`,
|
||||||
'Scripts'
|
'Scripts'
|
||||||
);
|
);
|
||||||
core.addPath(userScriptsDir);
|
core.addPath(pythonPath);
|
||||||
} else {
|
} else {
|
||||||
const userScriptsDir = path.join(
|
// For Python >= 3.10 and architecture 'x64', or other versions, use the default user path
|
||||||
|
const pythonPath = path.join(
|
||||||
process.env['APPDATA'] || '',
|
process.env['APPDATA'] || '',
|
||||||
'Python',
|
'Python',
|
||||||
`Python${major}${minor}`,
|
`Python${major}${minor}`,
|
||||||
'Scripts'
|
'Scripts'
|
||||||
);
|
);
|
||||||
|
core.addPath(pythonPath);
|
||||||
|
}
|
||||||
|
|
||||||
// Add the default path to the environment PATH variable
|
if (
|
||||||
core.addPath(userScriptsDir);
|
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.
|
// On Linux and macOS, pip will create the --user directory and add it to PATH as needed.
|
||||||
|
|
Loading…
Reference in a new issue