Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54002,24 +54002,29 @@ class PipCache extends cache_distributor_1.default {
this.pythonVersion = pythonVersion;
}
async getCacheGlobalDirectories() {
let exitCode = 1;
let exitCode = 0;
let stdout = '';
let stderr = '';
// Add temporary fix for Windows
// On windows it is necessary to execute through an exec
// because the getExecOutput gives a non zero code or writes to stderr for pip 22.0.2,
// On Windows, it is necessary to execute through an exec
// because the getExecOutput gives a non-zero code or writes to stderr for pip 22.0.2,
// or spawn must be started with the shell option enabled for getExecOutput
// Related issue: https://github.com/actions/setup-python/issues/328
if (utils_1.IS_WINDOWS) {
const execPromisify = util_1.default.promisify(child_process.exec);
({ stdout: stdout, stderr: stderr } = await execPromisify('pip cache dir'));
try {
({ stdout, stderr } = await execPromisify('pip cache dir'));
}
catch (err) {
// Pip outputs warnings to stderr (e.g., --no-python-version-warning flag deprecation warning), causing false failure detection
// Related issue: https://github.com/actions/setup-python/issues/1034
// If an error occurs, capture stderr and set exitCode to 1 to indicate failure
stderr = err.stderr ?? err.message;
exitCode = 1;
}
}
else {
({
stdout: stdout,
stderr: stderr,
exitCode: exitCode
} = await exec.getExecOutput('pip cache dir'));
({ stdout, stderr, exitCode } = await exec.getExecOutput('pip cache dir'));
}
if (exitCode && stderr) {
throw new Error(`Could not get cache folder path for pip package manager`);
Expand Down
22 changes: 13 additions & 9 deletions src/cache-distributions/pip-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,28 @@ class PipCache extends CacheDistributor {
}

protected async getCacheGlobalDirectories() {
let exitCode = 1;
let exitCode = 0;
let stdout = '';
let stderr = '';

// Add temporary fix for Windows
// On windows it is necessary to execute through an exec
// because the getExecOutput gives a non zero code or writes to stderr for pip 22.0.2,
// On Windows, it is necessary to execute through an exec
// because the getExecOutput gives a non-zero code or writes to stderr for pip 22.0.2,
// or spawn must be started with the shell option enabled for getExecOutput
// Related issue: https://github.com/actions/setup-python/issues/328
if (IS_WINDOWS) {
const execPromisify = utils.promisify(child_process.exec);
({stdout: stdout, stderr: stderr} = await execPromisify('pip cache dir'));
try {
({stdout, stderr} = await execPromisify('pip cache dir'));
} catch (err) {
Comment thread
priyagupta108 marked this conversation as resolved.
// Pip outputs warnings to stderr (e.g., --no-python-version-warning flag deprecation warning), causing false failure detection
// Related issue: https://github.com/actions/setup-python/issues/1034
// If an error occurs, capture stderr and set exitCode to 1 to indicate failure
stderr = (err as any).stderr ?? (err as Error).message;
exitCode = 1;
}
Comment thread
priyagupta108 marked this conversation as resolved.
} else {
({
stdout: stdout,
stderr: stderr,
exitCode: exitCode
} = await exec.getExecOutput('pip cache dir'));
({stdout, stderr, exitCode} = await exec.getExecOutput('pip cache dir'));
}

if (exitCode && stderr) {
Expand Down
Loading