mtkennerly / poetry-dynamic-versioning

Plugin for Poetry to enable dynamic versioning based on VCS tags
MIT License
588 stars 36 forks source link

Check file existance for `[tool.poetry-dynamic-versioning.substitution]` #164

Closed cmarqu closed 2 months ago

cmarqu commented 5 months ago

When a list element of [tool.poetry-dynamic-versioning.substitution] does not use wildcards, it would be nice if the plugin printed a warning (or, optionally, an error) when the list element could not be found or is readonly in the file system.

mtkennerly commented 4 months ago

I've tried messing around with this a bit, but I'm not entirely satisfied with it.

The best option I could think of is enabling the warning when some environment variable is set. I don't mind adding that, but it's not as convenient as something automatic. Do you have any interest in this option for your use case?

cmarqu commented 4 months ago

For the non-wildcard case (2nd item), I would say it's a matter of "don't do that then". It's easy to either touch the docs/conf.py or comment out that line in the pyproject.toml if the warning is somehow breaking their build.

But if not automatic (which I would be fine with, it could be a breaking change for some of your users), instead of an environment variable which is not very discoverable, how about a setting in the pyproject.toml like on-version-substitution-fail = {"warn-non-wildcard", "warn-all", "error-non-wildcard", "error-all"}?

mtkennerly commented 2 months ago

I may revisit this in the future, but I'm still a bit hesitant about this one. For now, I'm introducing a general purpose env var for debug logging, which covers this case and could be expanded to others:

$ POETRY_DYNAMIC_VERSIONING_DEBUG=1 poetry build
No files found for substitution with glob '*.py' in folder 'C:\git\poetry-dynamic-versioning\tests\dependency-dynamic'
No files found for substitution with glob '*/__version__.py' in folder 'C:\git\poetry-dynamic-versioning\tests\dependency-dynamic'
No files found for substitution with glob '*/_version.py' in folder 'C:\git\poetry-dynamic-versioning\tests\dependency-dynamic'
No changes made during substitution in file 'C:\git\poetry-dynamic-versioning\tests\dependency-dynamic\dependency_dynamic\__init__.py'