diff --git a/action.yml b/action.yml index 5ef4fa7..e3c5ae8 100644 --- a/action.yml +++ b/action.yml @@ -6,7 +6,7 @@ inputs: python-version: description: "Version range or exact version of a Python version to use, using SemVer's version range syntax." default: "3.x" - required: true + required: false architecture: description: "The target architecture (x86, x64) of the Python interpreter." required: false @@ -37,6 +37,9 @@ inputs: description: "The dependency file(s) to cache." default: "pdm.lock" required: false + update-python: + description: "Whether to update the environment with the requested Python" + default: "true" outputs: python-version: description: "The installed Python or PyPy version. Useful when given a version range as input." diff --git a/dist/setup-pdm.js b/dist/setup-pdm.js index a097bc2..d1c9a01 100644 --- a/dist/setup-pdm.js +++ b/dist/setup-pdm.js @@ -77514,13 +77514,13 @@ async function fetchUrlAsBuffer(url) { } return Buffer.from(response.body); } -async function findPythonVersion(version, architecture, allowPreReleases) { +async function findPythonVersion(version, architecture, allowPreReleases, updateEnvironment = true) { let pythonVersion = ""; if (isPyPyVersion(version)) { const installed = await findPyPyVersion( version, architecture, - true, + updateEnvironment, false, allowPreReleases ); @@ -77533,7 +77533,7 @@ async function findPythonVersion(version, architecture, allowPreReleases) { const installed = await useCpythonVersion( version, architecture, - true, + updateEnvironment, false, allowPreReleases ); @@ -77621,6 +77621,7 @@ async function run() { const arch2 = core8.getInput("architecture") || os4.arch(); const pdmVersion = core8.getInput("version"); const pythonVersion = core8.getInput("python-version"); + const updateEnvironment = core8.getBooleanInput("update-python"); const allowPythonPreReleases = core8.getBooleanInput("allow-python-prereleases"); const cmdArgs = ["-"]; if (core8.getBooleanInput("prerelease")) { @@ -77640,7 +77641,7 @@ async function run() { if (core8.getBooleanInput("enable-pep582")) { core8.exportVariable("PYTHONPATH", getPep582Path(installOutput.install_location, installOutput.install_python_version)); } - const installedPython = await findPythonVersion(pythonVersion, arch2, allowPythonPreReleases); + const installedPython = await findPythonVersion(pythonVersion, arch2, allowPythonPreReleases, updateEnvironment); if (process.platform === "linux") { core8.exportVariable("LD_PRELOAD", "/lib/x86_64-linux-gnu/libgcc_s.so.1"); } diff --git a/src/setup-pdm.ts b/src/setup-pdm.ts index fc0145c..a49934e 100644 --- a/src/setup-pdm.ts +++ b/src/setup-pdm.ts @@ -29,6 +29,7 @@ async function run(): Promise { const arch = core.getInput('architecture') || os.arch(); const pdmVersion = core.getInput('version'); const pythonVersion = core.getInput('python-version'); + const updateEnvironment = core.getBooleanInput('update-python'); const allowPythonPreReleases = core.getBooleanInput('allow-python-prereleases'); const cmdArgs = ['-']; if (core.getBooleanInput('prerelease')) { @@ -50,7 +51,7 @@ async function run(): Promise { core.exportVariable('PYTHONPATH', getPep582Path(installOutput.install_location, installOutput.install_python_version)); } - const installedPython = await utils.findPythonVersion(pythonVersion, arch, allowPythonPreReleases); + const installedPython = await utils.findPythonVersion(pythonVersion, arch, allowPythonPreReleases, updateEnvironment); if (process.platform === 'linux') { // See https://github.com/actions/virtual-environments/issues/2803 diff --git a/src/utils.ts b/src/utils.ts index 38a350c..32e5a95 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -20,13 +20,13 @@ export async function fetchUrlAsBuffer(url: string): Promise { } -export async function findPythonVersion(version: string, architecture: string, allowPreReleases: boolean): Promise { +export async function findPythonVersion(version: string, architecture: string, allowPreReleases: boolean, updateEnvironment: boolean = true): Promise { let pythonVersion = ''; if (isPyPyVersion(version)) { const installed = await findPyPyVersion( version, architecture, - true, + updateEnvironment, false, allowPreReleases ); @@ -39,7 +39,7 @@ export async function findPythonVersion(version: string, architecture: string, a const installed = await useCpythonVersion( version, architecture, - true, + updateEnvironment, false, allowPreReleases );