Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How do I just use setup.cfg for versioning? #852

Unanswered
simkimsia asked this question in Q&A
Discussion options

I have a project i want to test commitzen with.

It uses only setup.cfg, so no setup.py because starting with setuptools version 30.3.0 (8 Dec 2016), the setup.cfg file is sufficient for packaging and you don't strictly need a setup.py file anymore.

The docs seem to only cover examples using setup.py. See https://commitizen-tools.github.io/commitizen/config/#custom-version-provider

when i tried the following command

cz bump --check-consistency --changelog 0.6.0b5 

i get

[NO_VERSION_SPECIFIED]
Check if current version is specified in config file, like:
version = 0.4.3

this is the first 3 lines in my setup.cfg

[metadata]
name = greendeploy_django_ltree
version = 0.6.0b5

so I was wondering if setup.cfg alone is enough to work with commitizen

Thank you

You must be logged in to vote

Replies: 1 comment 2 replies

Comment options

The example you cited is to create a new package containing a new version provider.

As a python user, if you are not using a pyproject.toml, then you should create a .cz.toml and tell it to modify the version in setup.cfg.

Sample:

# .cz.toml
[tool.commitizen]
version = "0.1.0"
update_changelog_on_bump = true
version_files = [
 "setup.cfg:version"
]

You can also run cz init which will guide you in the creation of a .cz.toml.

That's all you need.

If you want to create a new version provider that modifies the setup.cfg, that would be an awesome addition, in that case you'd have to use the link you cited first.

You must be logged in to vote
2 replies
Comment options

As a python user, if you are not using a pyproject.toml, then you should create a .cz.toml and tell it to modify the version in setup.cfg.

I am using a pyproject.toml

[build-system]
build-backend = "setuptools.build_meta"
requires = [
 "setuptools",
]
[tool.black]
target-version = ['py38']
[tool.ruff]
ignore-init-module-imports = true
[tool.mypy]
mypy_path = "src/"
namespace_packages = false
show_error_codes = true
strict = true
warn_unreachable = true
[[tool.mypy.overrides]]
module = "tests.*"
allow_untyped_defs = true

Should I still use the .cz.toml?

Sorry for the late reply.

Comment options

No, you are not using pyproject.toml to configure your project. You are using setup.cfg. You are using pyproject.toml to configure other dependencies.

You can see here how to configure your project using pyproject.toml: https://til.simonwillison.net/python/pyproject
is not that different from setup.cfg.

Let's see how things would look

If you were to use pyproject.toml

# pyproject.toml
[project]
name = "greendeploy_django_ltree"
version = "0.6.0b5"
[tool.commitizen]
version_provider = "pep621" # because you are using official python pyproject

If you keep setup.cfg

In this case commitizen is the source of truth for the version, and you have to explicitly modify the version on setup.cfg

# pyproject.toml
[tool.commitizen]
version_provider = "commitizen"
version = "0.6.0b5"
version_files = ["setup.cfg:version"]

setup.cfg:

[metadata]
name = greendeploy_django_ltree
version = 0.6.0b5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants

AltStyle によって変換されたページ (->オリジナル) /