From b2472ca4258a9ea3aee813980a0100a2261a42fc Mon Sep 17 00:00:00 2001 From: Frost Ming Date: Thu, 28 Nov 2024 09:15:12 +0800 Subject: [PATCH] fix: set python version first (#65) * fix: set python version first Signed-off-by: Frost Ming * fix: drop 3.8 and add 3.13 Signed-off-by: Frost Ming * fix: update pdm.lock Signed-off-by: Frost Ming --- .github/workflows/ci.yml | 2 +- dist/setup-pdm.js | 24 ++++++++++++------------ pdm.lock | 11 +++++++---- pyproject.toml | 12 ++++++------ src/setup-pdm.ts | 14 +++++++------- test.py | 2 +- 6 files changed, 34 insertions(+), 31 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8133e66..f87e4a3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] + python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] os: [windows-latest, ubuntu-latest, macos-latest] name: Test the action steps: diff --git a/dist/setup-pdm.js b/dist/setup-pdm.js index 1fff5fe..9c53657 100644 --- a/dist/setup-pdm.js +++ b/dist/setup-pdm.js @@ -84127,7 +84127,7 @@ var import_node_process4 = __toESM(require("node:process")); var core8 = __toESM(require_core()); var import_exec2 = __toESM(require_exec()); -// node_modules/.pnpm/setup-python@https+++codeload.github.com+actions+setup-python+tar.gz+2f078955e4d0f34cc7a8b0108b2eb7bbe154438e/node_modules/setup-python/src/utils.ts +// node_modules/.pnpm/github.com+actions+setup-python@2f078955e4d0f34cc7a8b0108b2eb7bbe154438e/node_modules/setup-python/src/utils.ts var cache = __toESM(require_cache2()); var core = __toESM(require_core()); var import_fs = __toESM(require("fs")); @@ -90391,12 +90391,12 @@ var defaults = { var got = create_default(defaults); var source_default2 = got; -// node_modules/.pnpm/setup-python@https+++codeload.github.com+actions+setup-python+tar.gz+2f078955e4d0f34cc7a8b0108b2eb7bbe154438e/node_modules/setup-python/src/find-python.ts +// node_modules/.pnpm/github.com+actions+setup-python@2f078955e4d0f34cc7a8b0108b2eb7bbe154438e/node_modules/setup-python/src/find-python.ts var os2 = __toESM(require("os")); var path3 = __toESM(require("path")); var semver2 = __toESM(require_semver4()); -// node_modules/.pnpm/setup-python@https+++codeload.github.com+actions+setup-python+tar.gz+2f078955e4d0f34cc7a8b0108b2eb7bbe154438e/node_modules/setup-python/src/install-python.ts +// node_modules/.pnpm/github.com+actions+setup-python@2f078955e4d0f34cc7a8b0108b2eb7bbe154438e/node_modules/setup-python/src/install-python.ts var path2 = __toESM(require("path")); var core2 = __toESM(require_core()); var tc = __toESM(require_tool_cache()); @@ -90485,7 +90485,7 @@ async function installCpythonFromRelease(release) { } } -// node_modules/.pnpm/setup-python@https+++codeload.github.com+actions+setup-python+tar.gz+2f078955e4d0f34cc7a8b0108b2eb7bbe154438e/node_modules/setup-python/src/find-python.ts +// node_modules/.pnpm/github.com+actions+setup-python@2f078955e4d0f34cc7a8b0108b2eb7bbe154438e/node_modules/setup-python/src/find-python.ts var core3 = __toESM(require_core()); var tc2 = __toESM(require_tool_cache()); function binDir(installDir) { @@ -90608,10 +90608,10 @@ function pythonVersionToSemantic(versionSpec, allowPreReleases) { return result; } -// node_modules/.pnpm/setup-python@https+++codeload.github.com+actions+setup-python+tar.gz+2f078955e4d0f34cc7a8b0108b2eb7bbe154438e/node_modules/setup-python/src/find-pypy.ts +// node_modules/.pnpm/github.com+actions+setup-python@2f078955e4d0f34cc7a8b0108b2eb7bbe154438e/node_modules/setup-python/src/find-pypy.ts var path5 = __toESM(require("path")); -// node_modules/.pnpm/setup-python@https+++codeload.github.com+actions+setup-python+tar.gz+2f078955e4d0f34cc7a8b0108b2eb7bbe154438e/node_modules/setup-python/src/install-pypy.ts +// node_modules/.pnpm/github.com+actions+setup-python@2f078955e4d0f34cc7a8b0108b2eb7bbe154438e/node_modules/setup-python/src/install-pypy.ts var os3 = __toESM(require("os")); var path4 = __toESM(require("path")); var core4 = __toESM(require_core()); @@ -90811,7 +90811,7 @@ function replaceX32toX86(architecture) { return architecture; } -// node_modules/.pnpm/setup-python@https+++codeload.github.com+actions+setup-python+tar.gz+2f078955e4d0f34cc7a8b0108b2eb7bbe154438e/node_modules/setup-python/src/find-pypy.ts +// node_modules/.pnpm/github.com+actions+setup-python@2f078955e4d0f34cc7a8b0108b2eb7bbe154438e/node_modules/setup-python/src/find-pypy.ts var semver4 = __toESM(require_semver4()); var core5 = __toESM(require_core()); var tc4 = __toESM(require_tool_cache()); @@ -91111,19 +91111,19 @@ async function run() { cmdArgs.push("--version", pdmVersion); cmdArgs.push("-o", "install-output.json"); try { + const installedPython = await findPythonVersion(pythonVersion, arch2, allowPythonPreReleases, updateEnvironment); + if (import_node_process4.default.platform === "linux") { + core8.exportVariable("LD_PRELOAD", "/lib/x86_64-linux-gnu/libgcc_s.so.1"); + } await (0, import_exec2.exec)(IS_WINDOWS ? "python" : "python3", cmdArgs, { input: await fetchUrlAsBuffer(INSTALL_SCRIPT_URL) }); const installOutput = JSON.parse(await readFile("install-output.json")); core8.debug(`Install output: ${installOutput}`); + core8.info(`Successfully setup ${installOutput.pdm_version} with Python ${installedPython}`); core8.setOutput("pdm-version", installOutput.pdm_version); core8.setOutput("pdm-bin", import_node_path2.default.join(installOutput.install_location, installOutput.pdm_bin)); core8.addPath(import_node_path2.default.dirname(installOutput.pdm_bin)); if (core8.getBooleanInput("enable-pep582")) core8.exportVariable("PYTHONPATH", getPep582Path(installOutput.install_location, installOutput.install_python_version)); - const installedPython = await findPythonVersion(pythonVersion, arch2, allowPythonPreReleases, updateEnvironment); - if (import_node_process4.default.platform === "linux") { - core8.exportVariable("LD_PRELOAD", "/lib/x86_64-linux-gnu/libgcc_s.so.1"); - } - core8.info(`Successfully setup ${installOutput.pdm_version} with Python ${installedPython}`); const matchersPath = import_node_path2.default.join(__dirname, "..", ".github"); core8.info(`##[add-matcher]${import_node_path2.default.join(matchersPath, "python.json")}`); if (isCacheAvailable()) diff --git a/pdm.lock b/pdm.lock index 0520ca6..aa6afeb 100644 --- a/pdm.lock +++ b/pdm.lock @@ -3,9 +3,12 @@ [metadata] groups = ["default", "dev"] -strategy = ["cross_platform", "inherit_metadata"] -lock_version = "4.4.1" -content_hash = "sha256:eb061d39de14e94263f38ecb20461dfb8a9fc7d73a3f9ede85ded6085701598a" +strategy = ["inherit_metadata"] +lock_version = "4.5.0" +content_hash = "sha256:c7bc8c77abe4c890545158d7bfdd811dce4a2658fa8ab856aa152f869973efab" + +[[metadata.targets]] +requires_python = ">=3.9" [[package]] name = "certifi" @@ -60,7 +63,7 @@ version = "2.1.0" requires_python = ">=3.8" summary = "HTTP library with thread-safe connection pooling, file post, and more." groups = ["dev"] -marker = "python_version == \"3.8\"" +marker = "python_version == \"3.13\"" files = [ {file = "urllib3-2.1.0-py3-none-any.whl", hash = "sha256:55901e917a5896a349ff771be919f8bd99aff50b79fe58fec595eb37bbc56bb3"}, {file = "urllib3-2.1.0.tar.gz", hash = "sha256:df7aa8afb0148fa78488e7899b2c59b5f4ffcfa82e6c54ccb9dd37c1d7b52d54"}, diff --git a/pyproject.toml b/pyproject.toml index a9152e5..2bf96c2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ name = "setup-pdm" version = "0.0.0" authors = [ { name = "Frost Ming", email = "mianghong@gmail.com" }, ] -requires-python = ">=3.8" +requires-python = ">=3.9" license = { text = "MIT" } [tool.pdm] @@ -10,9 +10,9 @@ distribution = false [tool.pdm.dev-dependencies] dev = [ - "urllib3; python_version=='3.8'", - "certifi; python_version=='3.9'", - "pytz; python_version=='3.10'", - "setuptools; python_version=='3.11'", - "six; python_version=='3.12'", + "certifi; python_version=='3.9'", + "pytz; python_version=='3.10'", + "setuptools; python_version=='3.11'", + "six; python_version=='3.12'", + "urllib3; python_version=='3.13'", ] diff --git a/src/setup-pdm.ts b/src/setup-pdm.ts index df219b8..f833f9c 100644 --- a/src/setup-pdm.ts +++ b/src/setup-pdm.ts @@ -41,22 +41,22 @@ async function run(): Promise { cmdArgs.push('-o', 'install-output.json') // Use the default python version installed with the runner try { + const installedPython = await utils.findPythonVersion(pythonVersion, arch, allowPythonPreReleases, updateEnvironment) + + 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') + } await exec(IS_WINDOWS ? 'python' : 'python3', cmdArgs, { input: await utils.fetchUrlAsBuffer(INSTALL_SCRIPT_URL) }) const installOutput: InstallOutput = JSON.parse(await utils.readFile('install-output.json')) core.debug(`Install output: ${installOutput}`) + core.info(`Successfully setup ${installOutput.pdm_version} with Python ${installedPython}`) core.setOutput('pdm-version', installOutput.pdm_version) core.setOutput('pdm-bin', path.join(installOutput.install_location, installOutput.pdm_bin)) core.addPath(path.dirname(installOutput.pdm_bin)) if (core.getBooleanInput('enable-pep582')) core.exportVariable('PYTHONPATH', getPep582Path(installOutput.install_location, installOutput.install_python_version)) - const installedPython = await utils.findPythonVersion(pythonVersion, arch, allowPythonPreReleases, updateEnvironment) - - 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 ${installOutput.pdm_version} with Python ${installedPython}`) const matchersPath = path.join(__dirname, '..', '.github') core.info(`##[add-matcher]${path.join(matchersPath, 'python.json')}`) if (utils.isCacheAvailable()) diff --git a/test.py b/test.py index 2c459d4..1d3fe3b 100644 --- a/test.py +++ b/test.py @@ -4,11 +4,11 @@ import unittest PACKAGE_MAP = { - "3.8": "urllib3", "3.9": "certifi", "3.10": "pytz", "3.11": "setuptools", "3.12": "six", + "3.13": "urllib3", }