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

CLI for getting JSON? #197

Closed
henryiii opened this issue Oct 10, 2024 · 4 comments
Closed

CLI for getting JSON? #197

henryiii opened this issue Oct 10, 2024 · 4 comments

Comments

@henryiii
Copy link
Collaborator

henryiii commented Oct 10, 2024

I think it might be handy to have a CLI for getting as_json(). This would be useful to quickly get info from a PEP 621 project without having to trigger more expensive processes. This is not a universal solution to pypa/build#579, but it would be very fast when it works.

@dnicolodi
Copy link
Contributor

I think that this could be useful, but it could also give the false impression that it is possible to extract information from a package without running the build backend. In the case of meson-python, for example, this pyproject.toml is perfectly fine to generate a valid and complete Python wheel:

[build-system]
build-backend = 'mesonpy'
requires = ['meson-python']

meson-python in this case derives the wheel name and version (and soon also license) from meson.build. However, the tool proposed here could only report that the pyproject.toml is invalid as it does not contain a project table. Note that this feature of meson-python is defined in PEP 621 and it is not a funky extension.

@henryiii
Copy link
Collaborator Author

henryiii commented Oct 14, 2024

If a "only read PEP 621 metadata" CLI was acceptable anywhere, it would be here, though - unlike something like build, this package is focused only on reading pyproject metadata.

A file that doesn't use PEP 621 would just produce an error stating there is no metadata to read. Ideally with a unique error code so a pipeline could then do a more expensive read.

@dnicolodi
Copy link
Contributor

A file that doesn't use PEP 621 would just produce an error stating there is no metadata to read. Ideally with a unique error code so a pipeline could then do a more expensive read.

Build backends can allow any field in the project table to be dynamic. How is this tool going to signal that a specific field is dynamic? The consumer of the data would need to first check whether the fileds it is interested into are declared as dynamic. This requires enough logic that however it is implemented, I don't think consuming JSON or TOML makes much of a difference. If it makes a difference, there are several toml2json implementations that can be used to convert TOML into JSON.

@henryiii
Copy link
Collaborator Author

It's not just the conversion, it's also the fact we do things like load README, license files, etc. Though yes, handling project.dynamic is tricky, though I guess we could misuse Dynamic (along with the fact that version can't be Dynamic, so if it's missing, it's project.dynamic). We could also set these to null, since JSON (unlike TOML) does have that concept. But yes, maybe it's limited and not straight forward enough to do.

@henryiii henryiii closed this as not planned Won't fix, can't repro, duplicate, stale Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants