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

Idea: warn on required pyproject.toml configurations missing #219

Open
d33bs opened this issue Feb 18, 2025 · 2 comments
Open

Idea: warn on required pyproject.toml configurations missing #219

d33bs opened this issue Feb 18, 2025 · 2 comments

Comments

@d33bs
Copy link

d33bs commented Feb 18, 2025

Thanks for the great work on this project - it's super useful!

I noticed recently that I had somehow forgotten to add the following configuration to my pyproject.toml:

[build-system]
requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning>=1.0.0,<2.0.0"]
build-backend = "poetry_dynamic_versioning.backend"

That said, I had still installed poetry and poetry-dynamic-versioning into my venv, and included all other relevant configuration within the pyproject.toml file. This resulted in poetry build commands showing output references to the version I expected from poetry-dynamic-versioning rendering and files under my dist which were a later ("incorrect") version than expected (following I believe setuptools defaults which bumped the patch semver, among other things).

I wondered if it might make sense to inform the user about the potential for this to happen; perhaps as a warning when issuing poetry build or earlier to help state that there is a conflict / unexpected overlap from the configuration. I'm not sure if this is possible because of my erroneous configuration, but I thought it might be since poetry build showed the expected version. Thanks in advance for your thoughts on this (even if it's to say no, this isn't a very good idea or possible under the circumstances)!

@d33bs d33bs changed the title Idea: warn on pyproject.toml configurations missing Idea: warn on required pyproject.toml configurations missing Feb 18, 2025
@mtkennerly
Copy link
Owner

Hi! On one hand, I agree this would be nice to add, but my concern with enabling it by default would be the risk of false positives, if the user doesn't want the setting or is using a different means to achieve the same effect. For example, I'm not sure if it exists today, but I could imagine someone using a different build backend that can delegate to multiple configured Poetry plugins, since more than one plugin might want its custom build backend activated.

There is the POETRY_DYNAMIC_VERSIONING_DEBUG environment variable that could be enhanced with some checks related to this, but of course the issue there is discoverability.

For now, I'm not sure about a good solution here. I'd probably just recommend that users try running poetry-dynamic-versioning enable and take a look at what it changes - that should have added the missing config in this case.

@d33bs
Copy link
Author

d33bs commented Feb 24, 2025

Thanks @mtkennerly, I can see what you mean. What about following the pattern from Poetry core with a pre-commit-hooks.yaml for something like a pdv-check which can be optionally used to check the configuration? Perhaps this could be as simple as issuing the command you mentioned: poetry-dynamic-versioning enable to check for a non-zero exit.

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