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

How to make a release without version bumping? #812

Open
wookayin opened this issue Mar 2, 2023 · 7 comments
Open

How to make a release without version bumping? #812

wookayin opened this issue Mar 2, 2023 · 7 comments
Labels

Comments

@wookayin
Copy link

wookayin commented Mar 2, 2023

I've spent more than hour to figure out how to make a release while using setuptools_scm, but it's documented nowhere properly. Some relevant issues are #143 and #767, as well as a SO thread, but they seem pretty outdated.

Here's how I am doing:

# pyproject.toml                                                   
                                                                   
[build-system]                                                     
requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2", "wheel"]
                                                                   
[tool.setuptools_scm]                                              
version_scheme = "release-branch-semver"
write_to = "mypackage/_version.py"                                   

setup.py:

setup(
   name='mypackage',
   # version='...',      # no version= ...
)

Running python setup.py sdist always shows the development version:

$ git checkout -b release-v1.1

# Note that the latest tagged version is v1.0
$ python setup.py --version 
1.1.0.dev35+g5478274

$ python setup.py sdist
(generates 1.1.0.dev35+g5478274 in the metadata)

I tried branch v1.1, creating a tag v1.1 but doesn't work -- it would simply bump up to version to 1.2.0dev0 instead.

I would want to have the version simply set as '1.1' to make a release, but there seems no way to prohibit setuptools_scm from changing the version. Any hints? I hope documentations about how to make a release can be improved.

@wookayin
Copy link
Author

wookayin commented Mar 5, 2023

Surprisingly, when the following section exists in pyproject.toml,

[tool.setuptools_scm]
write_to = "pkg/_version.py"

setup(version=...) will be completely ignored and the version will be always set by setuptools_scm (no overriding allowed).

kjsanger added a commit to kjsanger/npg-irods-python that referenced this issue Mar 9, 2023
setuptools has recently deprecated legacy versioning, so we moved to
configuring setuptools_scm with the no-guess-dev option. It appears
that a release always adds version bump in addition to the git tag.

e.g. release 1.0.1 reports its version as
1.0.1.post1.dev0+g3859438.d20230308

while 3859438 is the commit that was tagged on master as 1.0.1, the
version has a post-release suffix (and appears to have been
interpreted as a dev release?).

The issue reported here appears to be the same:
pypa/setuptools-scm#812

Trying setuptools-git-versioning instead in the hope that it is less
"clever".
@RonnyPfannschmidt
Copy link
Contributor

It's not clear what you are doing, is the version file by chance checked into git instead of being ignored?

@wookayin
Copy link
Author

No, _version.py is gitignored and not tracked (for sure). What else informaiton are you looking for? I think I provided enough information and code excerpts.

Basically, if setuptools_scm is installed, and pyproject.toml configures setuptools_scm in [build-system], python setup.py --version will ignore setup.py version and always show a devel version managed by setuptools_scm. I'd like to know what's a recommended way for release process.

@RonnyPfannschmidt
Copy link
Contributor

The output of the SETUPTOOLS_SCM_DEBUG=1 python setup.py - -version would help

@wookayin
Copy link
Author

wookayin commented Apr 5, 2023

$ git clone https://github.com/wookayin/gpustat
$ cd gpustat
$ git checkout 5a18b1c16ab523d0b9709dd835cf354432b28c3b    # release/1.1
$ cat setup.py | grep __version__
__version__ = '1.1.0'
...
version=__version__,

pyproject.toml:

[build-system]
requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2", "wheel"]

[tool.setuptools_scm]
write_to = "gpustat/_version.py"

The debug output:

$ SETUPTOOLS_SCM_DEBUG=1 python setup.py --version

finalize hook {'name': 'gpustat', 'version': '1.1.0', 'author': 'Jongwook Choi', 'author_email': '[email protected]', 'maintainer': None, 'maintainer_email': None, 'url': 'https://github.com/wookayin/gpustat', 
... (omitted) ...
}
abs root {'root': '.', 'relative_to': 'pyproject.toml'}
file pyproject.toml
root '/home/wookayin/gpustat'
relative_to 'pyproject.toml'
dist name: gpustat
version_from_ep setuptools_scm.parse_scm /home/wookayin/gpustat
looking for ep setuptools_scm.parse_scm /home/wookayin/gpustat
found ep EntryPoint(name='.git', value='setuptools_scm.git:parse', group='setuptools_scm.parse_scm') in /home/wookayin/gpustat
GIT_EDITOR nvim
----
cmd:
     git --git-dir /home/wookayin/gpustat/.git rev-parse --show-prefix
 in: /home/wookayin/gpustat
GIT_EDITOR nvim
out:


real root /home/wookayin/gpustat
GIT_EDITOR nvim
----
cmd:
     git --git-dir /home/wookayin/gpustat/.git describe --dirty --tags --long --match "*[0-9]*"
 in: /home/wookayin/gpustat
GIT_EDITOR nvim
out:
     v1.0-37-g5a18b1c

----
cmd:
     git --git-dir /home/wookayin/gpustat/.git rev-parse --abbrev-ref HEAD
 in: /home/wookayin/gpustat
GIT_EDITOR nvim
out:
     release/1.1

----
cmd:
     git --git-dir /home/wookayin/gpustat/.git -c log.showSignature=false log -n 1 HEAD --format=%cI
 in: /home/wookayin/gpustat
GIT_EDITOR nvim
out:
     2023-04-05T10:17:35-04:00

tag v1.0
tag 'v1.0' parsed to {'version': 'v1.0', 'prefix': '', 'suffix': ''}
version pre parse v1.0
version <Version('1.0')>
version v1.0 -> 1.0
EntryPoint(name='.git', value='setuptools_scm.git:parse', group='setuptools_scm.parse_scm') <ScmVersion 1.0 dist=37 node=g5a18b1c dirty=False branch=release/1.1>
scm version <ScmVersion 1.0 dist=37 node=g5a18b1c dirty=False branch=release/1.1>
config {'version_scheme': 'guess-next-dev', 'local_scheme': 'node-and-date'}
ep found: guess-next-dev
version 1.1.dev37
ep found: node-and-date
local_version +g5a18b1c
1.1.dev37+g5a18b1c

Expected: 1.1.0 (it should not override version=... in setup.py)

@RonnyPfannschmidt
Copy link
Contributor

Thanks for the note, as far as I can tell this is a oversight in the code for self config, it should warn/fail if Version is statically configured as keyword

It's also incorrect usage to set Version while using setuptools_scm

I believe a example for the release Branch semver as release scheme is needed

@RonnyPfannschmidt
Copy link
Contributor

please try again with the current version of setuptools_scm - a bug regading config loading vs setup.py usage has been resolved

the last output indicates using the default config instead of the release branch semver one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants