You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thank you @utdrmac! I've played around with this. It's not yet finished, tests and documentation are missing and I need to fix the CI issue. But it works for me.
On a more basic level, I'm not sure about the name token. In #369 (comment), the comment said that "token" would be a misnomer and identifier could be another, better option. I haven't made up my mind yet. Any ideas about good naming is very appreciated.
Where exactly are you doing this? I'm using the CLI tool pysemver and there's no options for this, hence the FR/bug.
$ pysemver bump build -h
usage: semver bump build [-h] version
positional arguments:
version Version to raise
options:
-h, --help show this help message and exit
Install a Python version, for example: uv python install 3.13
Create a virtual environment (VENV): uv venv --python 3.13
Activate the VENV: source .venv/bin/activate
Install semver inside the VENV: uv pip install -e .
Run the CLI tool uv run pysemver ...
It should be similar for Windows, but I can't test it. If I execute all the steps from above, I get:
$ uv run pysemver bump build -h
usage: semver bump build [-h] [--token TOKEN] version
positional arguments:
version Version to raise
options:
-h, --help show this help message and exit
--token TOKEN The token to use for build
I'm not on any "branch". I simply executed pip install semver and this is what I got. Seems I need to wait until that feature/branch is merged to main.
And that's the issue here. 😸 Currently, the change lives only inside the mentioned branch. It's not yet released to PyPI. As such, installing it with pip gives you only version 3.0.2.
I simply executed pip install semver and this is what I got.
That doesn't work to get the latest version. That's expected if you install it by pip and not from the branch.
Seems I need to wait until that feature/branch is merged to main.
You have two options:
Test it with the above procedure and report back. It would help me to be sure everything works as expected.
Wait until I find the time to complete the pull request.
Thank you Matthew! I forgot that pip allows installation via git+http. Good idea! 👍
In regards to your interactive Python session, I think there is a misconception.
The algorithm about incrementing prerelease has a very simple logic:
Extract the prerelease part. In our case, it's 8.
Look if there is a number at the end:
True? Yes, we have a number. Increment it => 8 + 1 = 9
False? Add .0 at the end.
Return the new string. In our case it's 9
There is no automatism that adds "rc" as a result. If there is already a string then it is used and incremented as shown (and the --token option is only used, if we don't have a prerelease).
It's the exact same algorithm that is implemented in node's semver (JavaScript).
Details for node's semver
This is a short side track to JavaScript land and how they do it. Sometimes it helps how other languages implemented it.
However, that works in this case if you kind of control or now the structure of your prerelease. It's not a general solution.
If you really want a release candidate, my only recommendation is to create one right at the beginning as shown before. Then you won't have this problem.
Activity
Fix #466: CLI pass token for prerelease and build
tomschr commentedon Dec 9, 2025
Thank you @utdrmac! I've played around with this. It's not yet finished, tests and documentation are missing and I need to fix the CI issue. But it works for me.
On a more basic level, I'm not sure about the name
token. In #369 (comment), the comment said that "token" would be a misnomer andidentifiercould be another, better option. I haven't made up my mind yet. Any ideas about good naming is very appreciated.If you can try it out, let me know.
utdrmac commentedon Dec 9, 2025
Where exactly are you doing this? I'm using the CLI tool pysemver and there's no options for this, hence the FR/bug.
tomschr commentedon Dec 10, 2025
@utdrmac You are maybe in the wrong branch. I've opened PR#467 with branch
466-token.You can test it with the following steps (Linux & Mac):
git clone https://github.com/python-semver/python-semver.git && cd python-semver.git switch 466-tokenuvfrom https://github.com/astral-sh/uv and install it.uv python install 3.13uv venv --python 3.13source .venv/bin/activatesemverinside the VENV:uv pip install -e .uv run pysemver ...It should be similar for Windows, but I can't test it. If I execute all the steps from above, I get:
utdrmac commentedon Dec 10, 2025
I'm not on any "branch". I simply executed
pip install semverand this is what I got. Seems I need to wait until that feature/branch is merged to main.tomschr commentedon Dec 11, 2025
And that's the issue here. 😸 Currently, the change lives only inside the mentioned branch. It's not yet released to PyPI. As such, installing it with pip gives you only version 3.0.2.
That doesn't work to get the latest version. That's expected if you install it by pip and not from the branch.
You have two options:
utdrmac commentedon Dec 12, 2025
Learned about this neato feature of pip:
$ pip install git+https://github.com/python-semver/python-semver.git@466-tokentomschr commentedon Dec 12, 2025
Thank you Matthew! I forgot that pip allows installation via git+http. Good idea! 👍
In regards to your interactive Python session, I think there is a misconception.
The algorithm about incrementing prerelease has a very simple logic:
8.8 + 1 = 9.0at the end.9There is no automatism that adds "rc" as a result. If there is already a string then it is used and incremented as shown (and the
--tokenoption is only used, if we don't have a prerelease).It's the exact same algorithm that is implemented in node's semver (JavaScript).
Details for node's semver
This is a short side track to JavaScript land and how they do it. Sometimes it helps how other languages implemented it.
If you had already a release candidate, then it would be possible:
But you can't create magically an "rc." if it wasn't there. I think the CLI tool (and semver) is working exactly as it should.
If you really want that, you need to use the library:
However, that works in this case if you kind of control or now the structure of your prerelease. It's not a general solution.
If you really want a release candidate, my only recommendation is to create one right at the beginning as shown before. Then you won't have this problem.
Fix #466: CLI pass token for prerelease and build
Fix #466: CLI pass token for prerelease and build
Fix bump_build() silently returning an unchanged version for digitles…
Fix #466: CLI pass token for prerelease and build