Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly compute pyproject.toml path #213

Merged
merged 2 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading