How can I reference var from section into another section in pyproject.toml?

803 Views Asked by At

Hello I am building a pyproject object and I have the following two sections

[tool.poetry]
version = "0.1.0"

[tool.commitizen]
version = "0.1.0"

As you can see poetry uses the version in its section and commitizen in its section, the question is how to can I set only one version and share between sections?

Thanks

2

There are 2 best solutions below

0
finswimmer On BEST ANSWER

You cannot. The TOML syntax doesn't support this. (https://github.com/toml-lang/toml/issues/829)

0
Tlaloc-ES On

Finnaly I do with

[tool.poetry]
name = "aipose"
version = "1.0.0"

[tool.commitizen]
version = "1.0.0"
version_files = [
    "pyproject.toml:^version"
]
tag_format = "$version"

You can check a complete use with github actions in this repository: https://github.com/Tlaloc-Es/aipose/

Source: