diff --git a/dist/setup-pdm.js b/dist/setup-pdm.js index e3e5127..f3f44a7 100644 --- a/dist/setup-pdm.js +++ b/dist/setup-pdm.js @@ -6173,19 +6173,21 @@ async function run() { const pdmVersion = core3.getInput("version"); const pdmPackage = pdmVersion ? `pdm==${pdmVersion}` : "pdm"; const cmdArgs = ["-m", "pip", "install", "-U", pdmPackage]; - if (core3.getInput("prerelease")) { + if (core3.getInput("prerelease") === "true") { cmdArgs.push("--pre"); } try { - await findPythonVersion(INSTALL_VERSION, arch2); + let installedPython = await findPythonVersion(INSTALL_VERSION, arch2); await exec3.exec("python", cmdArgs); - const installed = await findPythonVersion(core3.getInput("python-version"), arch2); - await exec3.exec("pdm", ["use", "-f", installed.version]); - const pdmVersionOutput = (await (0, import_child_process.exec)("pdm --version")).stdout; + if (core3.getInput("python-version") !== INSTALL_VERSION) { + installedPython = await findPythonVersion(core3.getInput("python-version"), arch2); + } + await exec3.exec("pdm", ["use", "-f", installedPython.version]); + const pdmVersionOutput = (await (0, import_child_process.exec)("pdm --version")).stdout?.read(); if (process.platform === "linux") { core3.exportVariable("LD_PRELOAD", "/lib/x86_64-linux-gnu/libgcc_s.so.1"); } - core3.info(`Successfully setup ${pdmVersionOutput} with Python ${installed.version}`); + core3.info(`Successfully setup ${pdmVersionOutput} with Python ${installedPython.version}`); const matchersPath = import_path.default.join(__dirname, "..", ".github"); core3.info(`##[add-matcher]${import_path.default.join(matchersPath, "python.json")}`); } catch (error2) { diff --git a/src/setup-pdm.ts b/src/setup-pdm.ts index d9eccf5..2e1ec02 100644 --- a/src/setup-pdm.ts +++ b/src/setup-pdm.ts @@ -7,7 +7,7 @@ import path from "path"; const INSTALL_VERSION = "3.8"; -async function run() { +async function run(): Promise { const arch = core.getInput("architecture") || os.arch(); const pdmVersion = core.getInput("version"); const pdmPackage = pdmVersion ? `pdm==${pdmVersion}` : "pdm"; @@ -16,20 +16,22 @@ async function run() { cmdArgs.push("--pre"); } try { - await setupPython.findPythonVersion(INSTALL_VERSION, arch); + let installedPython = await setupPython.findPythonVersion(INSTALL_VERSION, arch); await exec.exec("python", cmdArgs); - const installed = await setupPython.findPythonVersion( - core.getInput("python-version"), - arch - ); - await exec.exec("pdm", ["use", "-f", installed.version]); - const pdmVersionOutput = (await execChild("pdm --version")).stdout; + if (core.getInput('python-version') !== INSTALL_VERSION) { + installedPython = await setupPython.findPythonVersion( + core.getInput("python-version"), + arch + ); + } + await exec.exec("pdm", ["use", "-f", installedPython.version]); + const pdmVersionOutput = (await execChild("pdm --version")).stdout?.read(); if (process.platform === 'linux') { // See https://github.com/actions/virtual-environments/issues/2803 core.exportVariable('LD_PRELOAD', '/lib/x86_64-linux-gnu/libgcc_s.so.1'); } core.info( - `Successfully setup ${pdmVersionOutput} with Python ${installed.version}` + `Successfully setup ${pdmVersionOutput} with Python ${installedPython.version}` ); const matchersPath = path.join(__dirname, '..', '.github'); core.info(`##[add-matcher]${path.join(matchersPath, 'python.json')}`);