Merge pull request #3 from pdm-project/pep582-path
This commit is contained in:
commit
494e36b1c3
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
@ -17,11 +17,9 @@ jobs:
|
|||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: pdm install -d -v
|
run: pdm install -v
|
||||||
env:
|
|
||||||
LD_PRELOAD: /lib/x86_64-linux-gnu/libgcc_s.so.1
|
|
||||||
|
|
||||||
- name: Verify python version
|
- name: Verify python version
|
||||||
run: pdm run python test.py
|
run: python test.py
|
||||||
env:
|
env:
|
||||||
PYTHON_VERSION: ${{ matrix.python-version }}
|
PYTHON_VERSION: ${{ matrix.python-version }}
|
||||||
|
@ -21,8 +21,9 @@ steps:
|
|||||||
architecture: x64 # The target architecture (x86, x64) of the Python interpreter. the same as actions/setup-python
|
architecture: x64 # The target architecture (x86, x64) of the Python interpreter. the same as actions/setup-python
|
||||||
version: 1.4.0 # The version of PDM to install. Leave it as empty to use the latest version from PyPI
|
version: 1.4.0 # The version of PDM to install. Leave it as empty to use the latest version from PyPI
|
||||||
prerelease: true # Allow prerelease versions to be installed
|
prerelease: true # Allow prerelease versions to be installed
|
||||||
|
enable-pep582: true # Enable PEP 582 package loading globally
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: pdm install -d # Then you can use pdm in the following steps.
|
run: pdm install # Then you can use pdm in the following steps.
|
||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
|
11
action.yml
11
action.yml
@ -6,16 +6,25 @@ inputs:
|
|||||||
python-version:
|
python-version:
|
||||||
description: "Version range or exact version of a Python version to use, using SemVer's version range syntax."
|
description: "Version range or exact version of a Python version to use, using SemVer's version range syntax."
|
||||||
default: "3.x"
|
default: "3.x"
|
||||||
|
required: true
|
||||||
architecture:
|
architecture:
|
||||||
description: "The target architecture (x86, x64) of the Python interpreter."
|
description: "The target architecture (x86, x64) of the Python interpreter."
|
||||||
|
required: false
|
||||||
token:
|
token:
|
||||||
description: Used to pull python distributions from actions/python-versions. Since there's a default, this is typically not supplied by the user.
|
description: Used to pull python distributions from actions/python-versions. Since there's a default, this is typically not supplied by the user.
|
||||||
default: ${{ github.token }}
|
default: ${{ github.token }}
|
||||||
|
required: false
|
||||||
version:
|
version:
|
||||||
description: The version of PDM to install.
|
description: The version of PDM to install.
|
||||||
|
required: false
|
||||||
prerelease:
|
prerelease:
|
||||||
description: Allow prerelease versions to be installed
|
description: Allow prerelease versions to be installed
|
||||||
default: false
|
default: 'false'
|
||||||
|
required: false
|
||||||
|
enable-pep582:
|
||||||
|
description: "Enable PEP 582 package loading globally."
|
||||||
|
default: 'true'
|
||||||
|
required: false
|
||||||
runs:
|
runs:
|
||||||
using: "node12"
|
using: "node12"
|
||||||
main: "dist/setup-pdm.js"
|
main: "dist/setup-pdm.js"
|
||||||
|
11
dist/setup-pdm.js
vendored
11
dist/setup-pdm.js
vendored
@ -6168,6 +6168,14 @@ var os2 = __toModule(require("os"));
|
|||||||
var import_child_process = __toModule(require("child_process"));
|
var import_child_process = __toModule(require("child_process"));
|
||||||
var import_path = __toModule(require("path"));
|
var import_path = __toModule(require("path"));
|
||||||
var INSTALL_VERSION = "3.8";
|
var INSTALL_VERSION = "3.8";
|
||||||
|
function getPep582Path() {
|
||||||
|
const installDir = process.env.pythonLocation || "";
|
||||||
|
if (IS_WINDOWS) {
|
||||||
|
return import_path.default.resolve(installDir, "Lib/site-packages/pdm/pep582");
|
||||||
|
} else {
|
||||||
|
return import_path.default.resolve(installDir, "lib", `python${INSTALL_VERSION}`, "site-packages/pdm/pep582");
|
||||||
|
}
|
||||||
|
}
|
||||||
async function run() {
|
async function run() {
|
||||||
const arch2 = core3.getInput("architecture") || os2.arch();
|
const arch2 = core3.getInput("architecture") || os2.arch();
|
||||||
const pdmVersion = core3.getInput("version");
|
const pdmVersion = core3.getInput("version");
|
||||||
@ -6179,6 +6187,9 @@ async function run() {
|
|||||||
try {
|
try {
|
||||||
let installedPython = await findPythonVersion(INSTALL_VERSION, arch2);
|
let installedPython = await findPythonVersion(INSTALL_VERSION, arch2);
|
||||||
await exec3.exec("python", cmdArgs);
|
await exec3.exec("python", cmdArgs);
|
||||||
|
if (core3.getInput("enable-pep582") === "true") {
|
||||||
|
core3.exportVariable("PYTHONPATH", getPep582Path());
|
||||||
|
}
|
||||||
if (core3.getInput("python-version") !== INSTALL_VERSION) {
|
if (core3.getInput("python-version") !== INSTALL_VERSION) {
|
||||||
installedPython = await findPythonVersion(core3.getInput("python-version"), arch2);
|
installedPython = await findPythonVersion(core3.getInput("python-version"), arch2);
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
{
|
{
|
||||||
"name": "pdm-action",
|
"name": "setup-pdm",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "The GitHub Action for using pdm as the package manager",
|
"description": "The GitHub Action for using pdm as the package manager",
|
||||||
"main": "src/index.js",
|
"main": "dist/setup-pdm.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "esbuild src/setup-pdm.ts --bundle --platform=node --outfile=dist/setup-pdm.js"
|
"build": "esbuild src/setup-pdm.ts --bundle --platform=node --outfile=dist/setup-pdm.js"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/pdm-project/pdm-action.git"
|
"url": "git+https://github.com/pdm-project/setup-pdm.git"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.2.6",
|
"@actions/core": "^1.2.6",
|
||||||
|
@ -1,31 +1,44 @@
|
|||||||
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 * as os from "os";
|
import {IS_WINDOWS} from 'setup-python/src/utils'
|
||||||
import { exec as execChild } from "child_process";
|
import * as os from 'os';
|
||||||
import path from "path";
|
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 || '';
|
||||||
|
if (IS_WINDOWS) {
|
||||||
|
return path.resolve(installDir, 'Lib/site-packages/pdm/pep582');
|
||||||
|
} else {
|
||||||
|
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];
|
const cmdArgs = ['-m', 'pip', 'install', '-U', pdmPackage];
|
||||||
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') {
|
||||||
|
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"),
|
core.getInput('python-version'),
|
||||||
arch
|
arch
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
await exec.exec("pdm", ["use", "-f", installedPython.version]);
|
await exec.exec('pdm', ['use', '-f', installedPython.version]);
|
||||||
const pdmVersionOutput = (await execChild("pdm --version")).stdout;
|
const pdmVersionOutput = (await execChild('pdm --version')).stdout;
|
||||||
if (process.platform === 'linux') {
|
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');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user