feat: add update-python input

Signed-off-by: Frost Ming <me@frostming.com>
This commit is contained in:
Frost Ming 2023-07-25 17:21:26 +08:00
parent 2d86acd19c
commit c21a0792fc
No known key found for this signature in database
GPG Key ID: 5BFA9CB4DDA943BF
4 changed files with 14 additions and 9 deletions

View File

@ -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."

9
dist/setup-pdm.js vendored
View File

@ -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");
}

View File

@ -29,6 +29,7 @@ async function run(): Promise<void> {
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<void> {
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

View File

@ -20,13 +20,13 @@ export async function fetchUrlAsBuffer(url: string): Promise<Buffer> {
}
export async function findPythonVersion(version: string, architecture: string, allowPreReleases: boolean): Promise<string> {
export async function findPythonVersion(version: string, architecture: string, allowPreReleases: boolean, updateEnvironment: boolean = true): Promise<string> {
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
);