Closed bram-tv closed 10 months ago
Thanks for the thorough report!
Always disable the plugin during
poetry build
(i.e. remove the version check): no idea if this would have unwanted effects
I think this is the right solution. That version check was meant to avoid duplicate work, especially back when the plugin had to rely on some brittle monkey-patching, but there are other checks now that do the same thing better (namely in _get_and_apply_version
when it checks _state.projects
).
When using the
poetry dynamic-versioning
command then the plugin is left enabled after a laterpoetry build
.This causes problems when later doing an install from the created .tar.gz file: it contains a pyproject.toml file which has the plugin enabled but it's not being used from inside the repository which then causes error.
(The .whl file works, but in my opinion the .tar.gz should also work)
Steps to reproduce
Example pyproject.toml:
(+ create an empty example.py file)
Without running
poetry dynamic-versioning
This work as expected:
The changes made to the packaged toml file:
version
was updatedtool.poetry-dynamic-versioning.enable
was changed from true to falseWith running
poetry dynamic-versioning
firstThe changes made to the packaged toml file:
version
was updatedtool.poetry-dynamic-versioning.enable
remains true: this is not OKAdditional information
Relevant code:
https://github.com/mtkennerly/poetry-dynamic-versioning/blob/322fe62f5a5270d324ca8a12b42224f67e822d2e/poetry_dynamic_versioning/cli.py#L71 This runs the apply version with
retain=True
. This causes the plugin to remain enable which is ok'ishhttps://github.com/mtkennerly/poetry-dynamic-versioning/blob/322fe62f5a5270d324ca8a12b42224f67e822d2e/poetry_dynamic_versioning/__init__.py#L417 This code only disables the plugin when the version number changed. When
poetry dynamic-versioning
was first run the version number is already set so it doesn't detect a change and leaves the plugin as enabled.Possible solutions
poetry dynamic-versioning
: this might be undesirable: it would require someone to re-enable the plugin after testing/runningpoetry dynamic-versioning
poetry build
(i.e. remove the version check): no idea if this would have unwanted effectspoetry dynamic-versioning
to control theretain
flag (i.e. that it can be run with--retain=false
(or--no-retain
or--disable
or ...) which would change the enable to false