I am looking at https://github.com/pypa/setuptools_scm
and I read this part https://github.com/pypa/setuptools_scm#version-number-construction
and i quote
Semantic versioning for projects with release branches. The same as guess-next-dev (incrementing the pre-release or micro segment) if on a release branch: a branch whose name (ignoring namespace) parses as a version that matches the most recent tag up to the minor segment. Otherwise if on a non-release branch, increments the minor segment and sets the micro segment to zero, then appends .devN.
How does this work?
Assuming my setup is at this commit https://github.com/simkimsia/test-setup-py/commit/5ebab14b16b63090ad0554ad8f9a77a28b047323
and the same repo, how do i increment the version by branching?
What i tried on 2022-03-15
I updated some files on main branch.
Then i did the following
python -m pip install --upgrade "pip ~= 21.3"
pip install pip-tools "pip-tools ~= 6.5"
git init .
git add .
git commit -m '♻️ REFACTOR'
git tag -a v0.0.0 -m ' First tag v0.0.0'
pip-compile
pip-sync
pip install -e .
Then i push my changes including the tag
So this commit is https://github.com/simkimsia/test-setup-py/commit/75838db70747fd06cc190218562d0548baa16e9d
When I run python -m demopublicpythonproject
the version that appears is correct
The version number that appears here is based on https://github.com/simkimsia/test-setup-py/blob/75838db70747fd06cc190218562d0548baa16e9d/demopublicpythonproject/framework/__init__.py#L14
Then i branch off
git checkout -b v0.0.1
Then i added a pyproject.toml and set to release-branch
# pyproject.toml
[build-system]
requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2"]
version_scheme = "release-branch-semver"
see https://github.com/simkimsia/test-setup-py/blob/v0.0.1/pyproject.toml
Then i run
python -m setuptools_scm
I get
/Users/kimsia/.venv/test-setup-py-py3812/bin/python: No module named setuptools_scm
In any case i run the following
pip-compile
pip-sync
pip install -e .
git commit -m 'Attempt to do branch semver'
then i have this commit as a result https://github.com/simkimsia/test-setup-py/commit/527885531afe37014dc66432a43a402ec0808caa
When I run python -m demopublicpythonproject
I get this image
The version appears to follow based on the branch number but i might be wrong because the latest tag is v0.0.0
so i
git checkout -b main
git checkout -b v0.1.0
pip-sync
pip install -e .
python -m demopublicpythonproject
i get a different version number
0.0.1.dev1+g45f5696 but not 0.1.0