mirror of
https://github.com/actions/setup-python.git
synced 2025-06-08 06:27:00 +09:00
logic to update install oath with --user flg
This commit is contained in:
parent
5db1cf9a59
commit
7469b5436f
2 changed files with 48 additions and 10 deletions
27
dist/setup/index.js
vendored
27
dist/setup/index.js
vendored
|
@ -96164,13 +96164,32 @@ function useCpythonVersion(version, architecture, updateEnvironment, checkLatest
|
|||
core.addPath(installDir);
|
||||
core.addPath(_binDir);
|
||||
if (utils_1.IS_WINDOWS) {
|
||||
// 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`
|
||||
// Extract version details
|
||||
const version = path.basename(path.dirname(installDir));
|
||||
const major = semver.major(version);
|
||||
const minor = semver.minor(version);
|
||||
const userScriptsDir = path.join(process.env['APPDATA'] || '', 'Python', `Python${major}${minor}`, 'Scripts');
|
||||
const basePath = process.env['APPDATA'] || '';
|
||||
let versionSuffix = `${major}${minor}`;
|
||||
// Append '-32' for x86 architecture if Python version is >= 3.10
|
||||
if (architecture === 'x86' &&
|
||||
(major > 3 || (major === 3 && minor >= 10))) {
|
||||
versionSuffix += '-32';
|
||||
}
|
||||
else if (architecture === 'arm64') {
|
||||
versionSuffix += '-arm64';
|
||||
}
|
||||
// Append 't' for freethreaded builds
|
||||
if (freethreaded) {
|
||||
versionSuffix += 't';
|
||||
if (architecture === 'x86-freethreaded') {
|
||||
versionSuffix += '-32';
|
||||
}
|
||||
else if (architecture === 'arm64-freethreaded') {
|
||||
versionSuffix += '-arm64';
|
||||
}
|
||||
}
|
||||
// Add user Scripts path
|
||||
const userScriptsDir = path.join(basePath, 'Python', `Python${versionSuffix}`, 'Scripts');
|
||||
core.addPath(userScriptsDir);
|
||||
}
|
||||
// On Linux and macOS, pip will create the --user directory and add it to PATH as needed.
|
||||
|
|
|
@ -49,8 +49,8 @@ export async function useCpythonVersion(
|
|||
// Use the freethreaded version if it was specified in the input, e.g., 3.13t
|
||||
freethreaded = true;
|
||||
}
|
||||
core.debug(`Semantic version spec of ${version} is ${semanticVersionSpec}`);
|
||||
|
||||
core.debug(`Semantic version spec of ${version} is ${semanticVersionSpec}`);
|
||||
if (freethreaded) {
|
||||
// Free threaded versions use an architecture suffix like `x64-freethreaded`
|
||||
core.debug(`Using freethreaded version of ${semanticVersionSpec}`);
|
||||
|
@ -152,17 +152,36 @@ export async function useCpythonVersion(
|
|||
core.addPath(_binDir);
|
||||
|
||||
if (IS_WINDOWS) {
|
||||
// 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`
|
||||
// Extract version details
|
||||
const version = path.basename(path.dirname(installDir));
|
||||
const major = semver.major(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' &&
|
||||
(major > 3 || (major === 3 && minor >= 10))
|
||||
) {
|
||||
versionSuffix += '-32';
|
||||
} else if (architecture === 'arm64') {
|
||||
versionSuffix += '-arm64';
|
||||
}
|
||||
// Append 't' for freethreaded builds
|
||||
if (freethreaded) {
|
||||
versionSuffix += 't';
|
||||
if (architecture === 'x86-freethreaded') {
|
||||
versionSuffix += '-32';
|
||||
} else if (architecture === 'arm64-freethreaded') {
|
||||
versionSuffix += '-arm64';
|
||||
}
|
||||
}
|
||||
// Add user Scripts path
|
||||
const userScriptsDir = path.join(
|
||||
process.env['APPDATA'] || '',
|
||||
basePath,
|
||||
'Python',
|
||||
`Python${major}${minor}`,
|
||||
`Python${versionSuffix}`,
|
||||
'Scripts'
|
||||
);
|
||||
core.addPath(userScriptsDir);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue