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

Non-monotonic development versions with release branch scheme #1025

Open
danchr opened this issue Mar 14, 2024 · 8 comments · May be fixed by #1087
Open

Non-monotonic development versions with release branch scheme #1025

danchr opened this issue Mar 14, 2024 · 8 comments · May be fixed by #1087

Comments

@danchr
Copy link
Contributor

danchr commented Mar 14, 2024

I use setuptools_scm for versioning hg-git, with the release-branch-semver scheme, where I have release branches named e.g. 1.0.x and 1.1.x. When doing a stable release, I do it on the release branch and merge it into default. Unfortunately, the devN is merely calculated as the length to the most recent tag, which then makes it decrease after a minor release is merged into the main development branch.

I checked, and I can reproduce this using both Mercurial and Git sources. For example, the version determined relative to 1.1.0 is 1.2.0.dev26+g7069705 whereas after the merge, it.s 1.2.0.dev17+g5b33fad.

As best I can tell, you cannot easily customise the devN part. For release-branch-semver, I believe it should either:

  1. Use some monotonically increasing value, like the date or a timestamp.
  2. Somehow take the minor into account, e.g. by multiplying the distance by 100 or 1000 times the minor release number.
@RonnyPfannschmidt
Copy link
Contributor

Currently there is no sane way to calculate the combined maximum distance

Both hg and git only provide a minimal distance

Is there a practical use case for the need of those numbers or is it only a preference

I'm not aware of a consistent/safe way to implement what you ask for

@danchr
Copy link
Contributor Author

danchr commented Mar 18, 2024

Yeah, I looked at the contents of .hg_archival.txt (that's what lead me to filing #1024) and I see that's it's relatively limited what you actually have. That's why I was thinking of using the minor version since that's what's most likely to lead to the “backtracking” dev part. In this case, something like:

  • 1.2.0.dev26+g7069705 would be relative to 1.1.0 whereas 1.2.0.dev1017 would be relative to 1.1.1.

Anyway, there isn't much practical use of this; I just wanted to use the GitLab package registry for installing the latest development build, and was rather surprised that it didn't work.

@RonnyPfannschmidt
Copy link
Contributor

ah, now i get the problem - and indeed - both git and hg dont allow for that easily

however i beleive another mistake is in there - we should add some type of increment for distances so that the commit doesnt hit

aka https://github.com/pypa/setuptools_scm/blob/main/src/setuptools_scm/version.py#L299 needs to trigger a bump

we need a better test there, but basically - you shouldnt be hitting 1.2.0.dev after a merge

i need to line up the examples, a bit better

@RonnyPfannschmidt
Copy link
Contributor

please outline the way you use branches, tags and merges in more detail

i suspect we need errors in the release branch semver scheme for certain cases + better handling of missed increments

@yakaviuk
Copy link

yakaviuk commented Sep 2, 2024

Hi,
we also have similar issue:
in master branch in GitLab we create a tag, and pipeline in master branch is run once tag is created. Usually it works fine, but sometimes (we can't find specific circumstates) package name has incorrect tag (in the name).
E.g. if all is fine:
We created tag "1.0.28" in GitLab UI, and in "build" stage run "python -m build", as a result got artifact with name:
app_name-1.0.28.tar.gz and app_name-1.0.28-py3-none-any.whl

But sometimes it works like that:
tag "1.0.29" is created in GitLab UI,
according to git describe tag exists:

$ git describe --always
1.0.29
$ git describe --tags
1.0.29

But "python -m build" creates artifacts with incorrect names:
Successfully built app_name-1.0.30.dev0+g61e35b4e.d20240902.tar.gz and app_name-1.0.30.dev0+g61e35b4e.d20240902-py3-none-any.whl

(Instead of "1.0.29" there is "1.0.30.dev0+g61e35b4e.d20240902" in package name).

Looks like it doesn't depend on versions (newer version of setuptools-scm and Gitlab versions 16.4 and higher).

@RonnyPfannschmidt
Copy link
Contributor

That is a different issue when the workdir state is dirty

Please cross-check whether you change a committed file in the build process

@yakaviuk
Copy link

yakaviuk commented Sep 5, 2024

That is a different issue when the workdir state is dirty

Please cross-check whether you change a committed file in the build process

I though it is some bug on setuptools-scm or GitLab side, but it was because of dirty workdir (because of git lfs).
Thanks for pointing!

@danchr danchr linked a pull request Nov 18, 2024 that will close this issue
@danchr
Copy link
Contributor Author

danchr commented Nov 18, 2024

please outline the way you use branches, tags and merges in more detail

i suspect we need errors in the release branch semver scheme for certain cases + better handling of missed increments

Essentially, I have a stable branch, default, which has no tags. All tags are made on release branches; whenever I cut a new micro release, I merge it into default. As a result, the distance will decrease every time I make a release and merge it in.

I've posted a PR that seems to fi it for me 🙂

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

Successfully merging a pull request may close this issue.

3 participants