mtkennerly / poetry-dynamic-versioning

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

Dynamic versioning with dependencies #150

Closed jakekadir closed 8 months ago

jakekadir commented 8 months ago

I have several packages, all of which are published together with the same Git version tag. I'm looking to dynamically update pyproject.toml to change these dependencies' version numbers to the same as the project version. For example, package A (which depends on packages B and C) with version 1.1.1 should depend on B v1.1.1 and C v1.1.1.

I have attempted this by adding files=["pyproject.toml"] with the relevant regex pattern, and the dependency versions are correctly updated. However, when the changes are reverted, the package version number isn't reset to 0.0.0 and dynamic versioning's enable is left as false. The dependencies' versions are successfully reset to their placeholder value. This seems to be because the package version in pyproject.toml and the user-given files are updated and reverted separately, so whichever is reverted last is left as the remaining file.

mtkennerly commented 8 months ago

This seems to be because the package version in pyproject.toml and the user-given files are updated and reverted separately, so whichever is reverted last is left as the remaining file.

Good catch! The current order is: modify pyproject.toml version and enable -> for each substitution, record original state and apply changes -> revert version/enable -> revert substitutions. That doesn't work correctly for substitutions in pyproject.toml because the "original state" is being recorded too late.

I'll publish a fix for this.