question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Version bump tries to bump all matching of `version =` in pyproject.toml

See original GitHub issue

The problem

With version 7.3.0:

In pyproject.toml, the version of the main package is defined as version = 1.2.3 but some dependencies can be defined as such pyarrow = {version = "0.17.0", extras = [ "pandas" ] } and then semantic release is either bumping both version = the the computed version or trowing an error such as:

semantic-release version --patch
Creating new version
error: found conflicting versions: '1.2.3', '0.17.0'

Expected behavior

semantic release only bump the root version of the package and nothing in the dependencies section.

Additional context

Here is an example of pyproject.toml that you can use to reproduce

[tool.poetry]
name = "potatoes"
version = "1.2.3"
description = "I love potatoes"
authors = ["Potatoes <potatoes@potatoes.com>"]

[tool.poetry.dependencies]
python = "^3.8"
pyarrow = {version = "0.17.0", extras = [ "pandas" ] }

[tool.semantic_release]
version_variable = "pyproject.toml:version"
upload_to_pypi = false
commit_message = "Version generated by python-semantic-release [ci skip]"

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
danthcommented, Nov 13, 2020

I suggest we change the regular expression for version_variable to only match at the start of a line:

https://github.com/relekang/python-semantic-release/blob/da20b9bdd3c7c87809c25ccb2a5993a7ea209a22/semantic_release/history/__init__.py#L41-L49

1reaction
Cielquancommented, Nov 17, 2020

As pyproject.toml is a config file for not only packaging there are other tools that also have a blank version= setting like commitizen:

[tool.commitizen]
name = "cz_conventional_commits"
version = "0.5.2"
tag_format = "$version"
version_files = ["pyproject.toml:version"]

I think a regex approach for pyproject.toml is not good enough and would propose to use a toml library like tomlkit to actually load the toml file and extract the correct version. And of cause dump the bumped one afterwards.

The semantic-release config could then be like the following with two colons: <file : section : key>

[tool.semantic_release]
version_variable = ["pyproject.toml:tool.poetry:version"]

If 2 colons and file is *. toml: load it and extract elif 1 colon: regex and extract else: error

PS: I don’t know how commitizen solves the problem as they have version_files = ["pyproject.toml:version"] and it works.

Read more comments on GitHub >

github_iconTop Results From Across the Web

bump is also changing dependency versions in pyproject.toml ...
and the version of the dep matches the version of the project, then bump will change both versions. Is it possible to specify...
Read more >
Bump up version in Github workflow won't change the code
I moved this function to workflow and it won't change the version string at all!
Read more >
poetry-bumpversion - PyPI
The poetry version command only updates version in pyproject.toml file. ... Bumping version from 0.5.0 to 0.5.1 poetry-bumpversion: processed file: ...
Read more >
Poetry - The Blue Book
poetry saves all the information in the pyproject.toml file, including the project ... If you pass an argument, it will bump the version...
Read more >
Configuration — python-semantic-release 7.32.2 documentation
pyproject.toml file in a [tool.semantic_release] section ... Anything MAY change at any time. ... If you do not want to bump version to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found