Open wookayin opened 1 year ago
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).
It's not clear what you are doing, is the version file by chance checked into git instead of being ignored?
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.
The output of the SETUPTOOLS_SCM_DEBUG=1 python setup.py - -version
would help
$ 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': 'wookayin@gmail.com', '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)
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
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
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:
setup.py:
Running
python setup.py sdist
always shows the development version:I tried branch
v1.1
, creating a tagv1.1
but doesn't work -- it would simply bump up to version to1.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.