build action
This commit is contained in:
parent
8b3dbb8ada
commit
a1d9436bad
@ -14,7 +14,7 @@ Include the action in your workflow yaml file with the following arguments:
|
|||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
...
|
...
|
||||||
- uses: pdm-project/setup-pdm@v2.1
|
- uses: pdm-project/setup-pdm@main
|
||||||
name: Setup PDM
|
name: Setup PDM
|
||||||
with:
|
with:
|
||||||
python-version: 3.8 # Version range or exact version of a Python version to use, the same as actions/setup-python
|
python-version: 3.8 # Version range or exact version of a Python version to use, the same as actions/setup-python
|
||||||
|
750
dist/setup-pdm.js
vendored
750
dist/setup-pdm.js
vendored
File diff suppressed because it is too large
Load Diff
@ -1,56 +1,59 @@
|
|||||||
import * as core from '@actions/core';
|
import * as core from "@actions/core"
|
||||||
import * as exec from '@actions/exec';
|
import * as exec from "@actions/exec"
|
||||||
import * as setupPython from 'setup-python/src/find-python';
|
import * as setupPython from "setup-python/src/find-python"
|
||||||
import {IS_WINDOWS} from 'setup-python/src/utils'
|
import { IS_WINDOWS } from "setup-python/src/utils"
|
||||||
import * as os from 'os';
|
import * as os from "os"
|
||||||
import { exec as execChild } from 'child_process';
|
import { exec as execChild } from "child_process"
|
||||||
import path from 'path';
|
import path from "path"
|
||||||
|
|
||||||
const INSTALL_VERSION = '3.8';
|
const INSTALL_VERSION = "3.8"
|
||||||
|
|
||||||
function getPep582Path(): string {
|
function getPep582Path(): string {
|
||||||
const installDir = process.env.pythonLocation || '';
|
const installDir = process.env.pythonLocation || ""
|
||||||
if (IS_WINDOWS) {
|
if (IS_WINDOWS) {
|
||||||
return path.resolve(installDir, 'Lib/site-packages/pdm/pep582');
|
return path.resolve(installDir, "Lib/site-packages/pdm/pep582")
|
||||||
} else {
|
} else {
|
||||||
return path.resolve(installDir, 'lib', `python${INSTALL_VERSION}`, 'site-packages/pdm/pep582');
|
return path.resolve(installDir, "lib", `python${INSTALL_VERSION}`, "site-packages/pdm/pep582")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function run(): Promise<void> {
|
async function run(): Promise<void> {
|
||||||
const arch = core.getInput('architecture') || os.arch();
|
const arch = core.getInput("architecture") || os.arch()
|
||||||
const pdmVersion = core.getInput('version');
|
const pdmVersion = core.getInput("version")
|
||||||
const pdmPackage = pdmVersion ? `pdm==${pdmVersion}` : 'pdm';
|
const pdmPackage = pdmVersion ? `pdm==${pdmVersion}` : "pdm"
|
||||||
const cmdArgs = ['-m', 'pip', 'install', '-U', pdmPackage, 'toml'];
|
const cmdArgs = ["-m", "pip", "install", "-U", pdmPackage, "toml"]
|
||||||
if (core.getInput('prerelease') === 'true') {
|
if (core.getInput("prerelease") === "true") {
|
||||||
cmdArgs.push('--pre');
|
cmdArgs.push("--pre")
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
let installedPython = await setupPython.findPythonVersion(INSTALL_VERSION, arch);
|
let installedPython = await setupPython.findPythonVersion(INSTALL_VERSION, arch)
|
||||||
await exec.exec('python', cmdArgs);
|
await exec.exec("python", cmdArgs)
|
||||||
if (core.getInput('enable-pep582') === 'true') {
|
if (core.getInput("enable-pep582") === "true") {
|
||||||
core.exportVariable('PYTHONPATH', getPep582Path());
|
core.exportVariable("PYTHONPATH", getPep582Path())
|
||||||
}
|
}
|
||||||
if (core.getInput('python-version') !== INSTALL_VERSION) {
|
if (core.getInput("python-version") !== INSTALL_VERSION) {
|
||||||
installedPython = await setupPython.findPythonVersion(
|
installedPython = await setupPython.findPythonVersion(core.getInput("python-version"), arch)
|
||||||
core.getInput('python-version'),
|
|
||||||
arch
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
await exec.exec('pdm', ['use', '-f', 'python' + installedPython.version.replace(/^([23]\.\d+).*$/g, '$1')]);
|
await exec.exec("pdm", [
|
||||||
const pdmVersionOutput = (await execChild('pdm --version')).stdout;
|
"use",
|
||||||
if (process.platform === 'linux') {
|
"-f",
|
||||||
|
"python" + installedPython.version.replace(/^([23]\.\d+).*$/g, "$1"),
|
||||||
|
])
|
||||||
|
const pdmVersionOutput = (await execChild("pdm --version")).stdout
|
||||||
|
if (process.platform === "linux") {
|
||||||
// See https://github.com/actions/virtual-environments/issues/2803
|
// See https://github.com/actions/virtual-environments/issues/2803
|
||||||
core.exportVariable('LD_PRELOAD', '/lib/x86_64-linux-gnu/libgcc_s.so.1');
|
core.exportVariable("LD_PRELOAD", "/lib/x86_64-linux-gnu/libgcc_s.so.1")
|
||||||
}
|
}
|
||||||
core.info(
|
core.info(
|
||||||
`Successfully setup ${pdmVersionOutput && pdmVersionOutput.read()} with Python ${installedPython.version}`
|
`Successfully setup ${pdmVersionOutput && pdmVersionOutput.read()} with Python ${
|
||||||
);
|
installedPython.version
|
||||||
const matchersPath = path.join(__dirname, '..', '.github');
|
}`
|
||||||
core.info(`##[add-matcher]${path.join(matchersPath, 'python.json')}`);
|
)
|
||||||
} catch (error) {
|
const matchersPath = path.join(__dirname, "..", ".github")
|
||||||
core.setFailed(error.message);
|
core.info(`##[add-matcher]${path.join(matchersPath, "python.json")}`)
|
||||||
|
} catch (error: any) {
|
||||||
|
core.setFailed(error.message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
run();
|
run()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user