Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setuptools-scm: current version instead of next version

I want to use setuptools-scm to control my package version. My setup.py:

setuptools.setup(
...
    use_scm_version={'write_to': 'my-package/version.py'},
...
)

Currently I have v0.2 tag in my repo. I created new branch and added some commits. When I run python setup.py --version to create my-package/version.py file I get next tag v0.3 instead of current v0.2:

$ SETUPTOOLS_SCM_DEBUG=1 python3 setup.py --version
...
cmd 'git describe --dirty --tags --long --match *.*'
out b'v0.2-1-gb13420a\n'
cmd 'git rev-parse --abbrev-ref HEAD'
out b'feature-version-system\n'
tag v0.2
tag 'v0.2' parsed to {'version': 'v0.2', 'prefix': '', 'suffix': ''}
version pre parse v0.2
version <Version('0.2')>
version v0.2 -> 0.2
scm version <ScmVersion 0.2 d=1 n=gb13420a d=False b=feature-version-system>
config {'version_scheme': 'guess-next-dev', 'local_scheme': 'node-and-date'}
ep ('setuptools_scm.version_scheme', 'guess-next-dev')
ep found: guess-next-dev
ep ('setuptools_scm.local_scheme', 'node-and-date')
ep found: node-and-date
version 0.3.dev1
local_version +gb13420a
0.3.dev1+gb13420a  # <- I want to see 0.2.dev1+gb13420a here
$ git tag

v0.1
v0.2

I think it's wrong way, because my changes I'm working for are for current release tag v0.2, but setuptools_scm said that they belong v0.3. How to deal with it?

like image 501
approximatenumber Avatar asked Dec 31 '22 20:12

approximatenumber


2 Answers

For a while now setuptools-scm offers the option to use a post-release scheme, see setuptools_scm.version_scheme section. Then python setup.py --version and git describe --tag will give you the same information (different formatting though). To switch to a post-release scheme, include the following line in your setup.py:

setup(...
      use_scm_version={'version_scheme': 'post-release'},
      ...
      )
      
      
like image 163
David Avatar answered Jan 05 '23 00:01

David


setuptools_scm is working correctly, because it's creating a pre-release of the next version. According to PEP440 section on pre-releases:

The pre-release segment consists of an alphabetical identifier for the pre-release phase, along with a non-negative integer value. Pre-releases for a given release are ordered first by phase (alpha, beta, release candidate) and then by the numerical component within that phase.

They also show the example as:

X.YaN   # Alpha release
X.YbN   # Beta release
X.YrcN  # Release Candidate
X.Y     # Final release

That means that 0.3.dev1+gb13420a is a pre-release version of 0.3, and comes after 0.2. 0.2.dev1+gb13420a would mean it's a pre-release of 0.2, and would be older than 0.2.

like image 30
Jerr Avatar answered Jan 04 '23 23:01

Jerr