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
|
||||
steps:
|
||||
...
|
||||
- uses: pdm-project/setup-pdm@v2.1
|
||||
- uses: pdm-project/setup-pdm@main
|
||||
name: Setup PDM
|
||||
with:
|
||||
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 exec from '@actions/exec';
|
||||
import * as setupPython from 'setup-python/src/find-python';
|
||||
import {IS_WINDOWS} from 'setup-python/src/utils'
|
||||
import * as os from 'os';
|
||||
import { exec as execChild } from 'child_process';
|
||||
import path from 'path';
|
||||
import * as core from "@actions/core"
|
||||
import * as exec from "@actions/exec"
|
||||
import * as setupPython from "setup-python/src/find-python"
|
||||
import { IS_WINDOWS } from "setup-python/src/utils"
|
||||
import * as os from "os"
|
||||
import { exec as execChild } from "child_process"
|
||||
import path from "path"
|
||||
|
||||
const INSTALL_VERSION = '3.8';
|
||||
const INSTALL_VERSION = "3.8"
|
||||
|
||||
function getPep582Path(): string {
|
||||
const installDir = process.env.pythonLocation || '';
|
||||
const installDir = process.env.pythonLocation || ""
|
||||
if (IS_WINDOWS) {
|
||||
return path.resolve(installDir, 'Lib/site-packages/pdm/pep582');
|
||||
return path.resolve(installDir, "Lib/site-packages/pdm/pep582")
|
||||
} 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> {
|
||||
const arch = core.getInput('architecture') || os.arch();
|
||||
const pdmVersion = core.getInput('version');
|
||||
const pdmPackage = pdmVersion ? `pdm==${pdmVersion}` : 'pdm';
|
||||
const cmdArgs = ['-m', 'pip', 'install', '-U', pdmPackage, 'toml'];
|
||||
if (core.getInput('prerelease') === 'true') {
|
||||
cmdArgs.push('--pre');
|
||||
const arch = core.getInput("architecture") || os.arch()
|
||||
const pdmVersion = core.getInput("version")
|
||||
const pdmPackage = pdmVersion ? `pdm==${pdmVersion}` : "pdm"
|
||||
const cmdArgs = ["-m", "pip", "install", "-U", pdmPackage, "toml"]
|
||||
if (core.getInput("prerelease") === "true") {
|
||||
cmdArgs.push("--pre")
|
||||
}
|
||||
try {
|
||||
let installedPython = await setupPython.findPythonVersion(INSTALL_VERSION, arch);
|
||||
await exec.exec('python', cmdArgs);
|
||||
if (core.getInput('enable-pep582') === 'true') {
|
||||
core.exportVariable('PYTHONPATH', getPep582Path());
|
||||
let installedPython = await setupPython.findPythonVersion(INSTALL_VERSION, arch)
|
||||
await exec.exec("python", cmdArgs)
|
||||
if (core.getInput("enable-pep582") === "true") {
|
||||
core.exportVariable("PYTHONPATH", getPep582Path())
|
||||
}
|
||||
if (core.getInput('python-version') !== INSTALL_VERSION) {
|
||||
installedPython = await setupPython.findPythonVersion(
|
||||
core.getInput('python-version'),
|
||||
arch
|
||||
);
|
||||
if (core.getInput("python-version") !== INSTALL_VERSION) {
|
||||
installedPython = await setupPython.findPythonVersion(core.getInput("python-version"), arch)
|
||||
}
|
||||
await exec.exec('pdm', ['use', '-f', 'python' + installedPython.version.replace(/^([23]\.\d+).*$/g, '$1')]);
|
||||
const pdmVersionOutput = (await execChild('pdm --version')).stdout;
|
||||
if (process.platform === 'linux') {
|
||||
await exec.exec("pdm", [
|
||||
"use",
|
||||
"-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
|
||||
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(
|
||||
`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) {
|
||||
core.setFailed(error.message);
|
||||
`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: any) {
|
||||
core.setFailed(error.message)
|
||||
}
|
||||
}
|
||||
|
||||
run();
|
||||
run()
|
||||
|
Loading…
x
Reference in New Issue
Block a user