Skip to content

Commit

Permalink
Merge pull request #213 from PyO3/fix-212
Browse files Browse the repository at this point in the history
Correctly compute  `pyproject.toml` path
  • Loading branch information
messense authored Oct 2, 2023
2 parents c0df5c7 + 9658355 commit 96d3da7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
14 changes: 12 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -11581,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) {
Expand All @@ -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';
}
}
Expand Down
18 changes: 16 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -297,7 +305,7 @@ async function findVersion(args: string[]): Promise<string> {
`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')
Expand All @@ -311,9 +319,15 @@ async function findVersion(args: string[]): Promise<string> {
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') {
Expand Down

0 comments on commit 96d3da7

Please sign in to comment.