From df1b5c89d7e9679337f59d71f96b70aa44f638a2 Mon Sep 17 00:00:00 2001 From: messense Date: Mon, 2 Oct 2023 21:54:18 +0800 Subject: [PATCH 1/2] Correctly compute `pyproject.toml` path --- dist/index.js | 12 +++++++++++- src/index.ts | 16 +++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 6d31fde..a0cca76 100644 --- a/dist/index.js +++ b/dist/index.js @@ -11497,8 +11497,16 @@ function getRustTarget(args) { return ((_c = TARGET_ALIASES[process.platform]) === null || _c === void 0 ? void 0 : _c[target]) || target; } function getManifestDir(args) { + const workspace = process.env.GITHUB_WORKSPACE; + let workdir = core.getInput('working-directory'); + if (workdir.length > 0) { + workdir = path.join(workspace, workdir); + } + else { + workdir = workspace; + } const manifestPath = getCliValue(args, '--manifest-path') || getCliValue(args, '-m'); - return manifestPath ? path.dirname(manifestPath) : process.cwd(); + return manifestPath ? path.dirname(path.join(workdir, manifestPath)) : workdir; } function parseRustToolchain(content) { const toml = (0, toml_1.parse)(content.toString()); @@ -11594,10 +11602,12 @@ async function findVersion(args) { } } else { + core.info('maturin not found in [build-system.requires] section at ${pyprojectToml}, fallback to latest'); version = 'latest'; } } else { + core.info('No pyproject.toml found at ${pyprojectToml}, fallback to latest'); version = 'latest'; } } diff --git a/src/index.ts b/src/index.ts index a1f68e1..9a2143e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -176,9 +176,17 @@ function getRustTarget(args: string[]): string { } function getManifestDir(args: string[]): string { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + const workspace = process.env.GITHUB_WORKSPACE! + let workdir = core.getInput('working-directory') + if (workdir.length > 0) { + workdir = path.join(workspace, workdir) + } else { + workdir = workspace + } const manifestPath = getCliValue(args, '--manifest-path') || getCliValue(args, '-m') - return manifestPath ? path.dirname(manifestPath) : process.cwd() + return manifestPath ? path.dirname(path.join(workdir, manifestPath)) : workdir } function parseRustToolchain(content: string): string { @@ -311,9 +319,15 @@ async function findVersion(args: string[]): Promise { version = 'latest' } } else { + core.info( + 'maturin not found in [build-system.requires] section at ${pyprojectToml}, fallback to latest' + ) version = 'latest' } } else { + core.info( + 'No pyproject.toml found at ${pyprojectToml}, fallback to latest' + ) version = 'latest' } } else if (version !== 'latest') { From 96583551fe7e735711af3476985dcb5abb54f34e Mon Sep 17 00:00:00 2001 From: messense Date: Mon, 2 Oct 2023 22:08:02 +0800 Subject: [PATCH 2/2] nodejs semver does not support `==` --- dist/index.js | 2 +- src/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index a0cca76..89e776f 100644 --- a/dist/index.js +++ b/dist/index.js @@ -11589,7 +11589,7 @@ async function findVersion(args) { const maturin = requires.find(req => req.startsWith('maturin')); if (maturin) { core.info(`Found maturin version requirement ${maturin} specified in pyproject.toml`); - const versionSpec = pythonVersionToSemantic(maturin.replace('maturin', '').replace(',', ' ')); + const versionSpec = pythonVersionToSemantic(maturin.replace('maturin', '').replace(',', ' ').replace('==', '=')); core.debug(`maturin version spec: ${versionSpec}`); const release = await findReleaseFromManifest(versionSpec, 'x64'); if (release) { diff --git a/src/index.ts b/src/index.ts index 9a2143e..2e3dac6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -305,7 +305,7 @@ async function findVersion(args: string[]): Promise { `Found maturin version requirement ${maturin} specified in pyproject.toml` ) const versionSpec = pythonVersionToSemantic( - maturin.replace('maturin', '').replace(',', ' ') + maturin.replace('maturin', '').replace(',', ' ').replace('==', '=') ) core.debug(`maturin version spec: ${versionSpec}`) const release = await findReleaseFromManifest(versionSpec, 'x64')