reuse the python if possible

This commit is contained in:
Frost Ming 2021-04-06 09:10:59 +08:00
parent d8ffba5266
commit 51a3c26cfe
No known key found for this signature in database
GPG Key ID: 5BFA9CB4DDA943BF
2 changed files with 19 additions and 15 deletions

14
dist/setup-pdm.js vendored
View File

@ -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) {

View File

@ -7,7 +7,7 @@ import path from "path";
const INSTALL_VERSION = "3.8";
async function run() {
async function run(): Promise<void> {
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(
if (core.getInput('python-version') !== INSTALL_VERSION) {
installedPython = await setupPython.findPythonVersion(
core.getInput("python-version"),
arch
);
await exec.exec("pdm", ["use", "-f", installed.version]);
const pdmVersionOutput = (await execChild("pdm --version")).stdout;
}
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')}`);