From e201669395d083ea1385c1a3b8f18e042d66108a Mon Sep 17 00:00:00 2001 From: dajiaohuang <108231307+dajiaohuang@users.noreply.github.com> Date: Thu, 22 Oct 2026 04:44:29 +0800 Subject: [PATCH] Fix PyPy pip downgrade install state --- __tests__/install-pypy.test.ts | 10 +++++++++- dist/setup/index.js | 3 ++- src/install-pypy.ts | 5 ++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/__tests__/install-pypy.test.ts b/__tests__/install-pypy.test.ts index a9994c42..17029ccf 100644 --- a/__tests__/install-pypy.test.ts +++ b/__tests__/install-pypy.test.ts @@ -380,7 +380,15 @@ describe('installPyPy', () => { expect(spyDownloadTool).toHaveBeenCalled(); expect(spyExistsSync).toHaveBeenCalled(); expect(spyCacheDir).toHaveBeenCalled(); - expect(spyExec).toHaveBeenCalled(); + expect(spyExec).toHaveBeenCalledTimes(2); + expect(spyExec).toHaveBeenNthCalledWith( + 1, + expect.stringMatching(/ -m ensurepip$/) + ); + expect(spyExec).toHaveBeenNthCalledWith( + 2, + expect.stringMatching(/ -m pip install --upgrade pip$/) + ); }); it('found and install PyPy, pre-release fallback', async () => { diff --git a/dist/setup/index.js b/dist/setup/index.js index 21eebcaa..dd7f04c6 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -99820,7 +99820,8 @@ async function install_pypy_installPip(pythonLocation) { info('Installing and updating pip'); const pythonBinary = external_path_.join(pythonLocation, 'python'); await exec_exec(`${pythonBinary} -m ensurepip`); - await exec_exec(`${pythonLocation}/python -m pip install --ignore-installed pip`); + // Do not use --ignore-installed; pip must remove files from previous versions. + await exec_exec(`${pythonLocation}/python -m pip install --upgrade pip`); } function findRelease(releases, pythonVersion, pypyVersion, architecture, includePrerelease) { const options = { includePrerelease: includePrerelease }; diff --git a/src/install-pypy.ts b/src/install-pypy.ts index 43816f51..1dccfc20 100644 --- a/src/install-pypy.ts +++ b/src/install-pypy.ts @@ -177,9 +177,8 @@ async function installPip(pythonLocation: string) { const pythonBinary = path.join(pythonLocation, 'python'); await exec.exec(`${pythonBinary} -m ensurepip`); - await exec.exec( - `${pythonLocation}/python -m pip install --ignore-installed pip` - ); + // Do not use --ignore-installed; pip must remove files from previous versions. + await exec.exec(`${pythonLocation}/python -m pip install --upgrade pip`); } export function findRelease(