apply a consistent format to `setup.cfg` files
Project description
setup-cfg-fmt
apply a consistent format to setup.cfg files
installation
pip install setup-cfg-fmt
as a pre-commit hook
See pre-commit for instructions
Sample .pre-commit-config.yaml:
- repo: https://github.com/asottile/setup-cfg-fmt
rev: v3.2.0
hooks:
- id: setup-cfg-fmt
cli
Consult the help for the latest usage:
$ setup-cfg-fmt --help
what does it do?
sets a consistent ordering for attributes
For example, name and version (the most important metadata) will always
appear at the top.
[metadata]
-version = 1.14.4
-name = pre_commit
+name = pre_commit
+version = 1.14.4
normalizes dashes to underscores in project name
pipwill normalize names to dashesfoo_bar=>foo-barpython setup.py sdistproduces a filename with the name verbatimpip wheel .produces a filename with an underscore-normalized name
$ # with dashed name
$ python setup.py sdist && pip wheel -w dist .
...
$ ls dist/ | cat
setup_cfg_fmt-0.0.0-py2.py3-none-any.whl
setup-cfg-fmt-0.0.0.tar.gz
$ # with underscore name
$ python setup.py sdist && pip wheel -w dist .
...
$ ls dist/ | cat
setup_cfg_fmt-0.0.0-py2.py3-none-any.whl
setup_cfg_fmt-0.0.0.tar.gz
This makes it easier to upload packages to pypi since they end up with the same filename prefix.
[metadata]
-name = pre-commit
+name = pre_commit
normalizes dashes to underscores in keys
setuptools allows dashed names but does not document them.
[metadata]
name = pre-commit
-long-description = file: README.md
+long_description = file: README.md
adds long_description if README is present
This will show up on the pypi project page
[metadata]
name = pre_commit
version = 1.14.5
+long_description = file: README.md
+long_description_content_type = text/markdown
adds license_file / license if LICENSE exists
[metadata]
name = pre_commit
version = 1.14.5
+license = MIT
+license_file = LICENSE
set python_requires
A few sources are searched for guessing python_requires:
- the existing
python_requiressetting itself envlistintox.iniif present- python version
classifiersthat are already set - the
--min-py-versionargument
adds python version classifiers
classifiers are generated based on:
- the
python_requiressetting - the
--max-py-versionargument --include-version-classifiersis specified
name = pkg
version = 1.0
+classifiers =
+ Programming Language :: Python :: 3
+ Programming Language :: Python :: 3.7
+ Programming Language :: Python :: 3.8
+ Programming Language :: Python :: 3.9
+ Programming Language :: Python :: 3.10
+ Programming Language :: Python :: 3.11
+ ...
without --include-version-classifiers only the major version will be included:
name = pkg
version = 1.0
+classifiers =
+ Programming Language :: Python :: 3
sorts classifiers
[metadata]
name = pre_commit
version = 1.14.5
classifiers =
- Programming Language :: Python :: 3
+ Programming Language :: Python :: 3
+ Programming Language :: Python :: 3.6
removes empty options in any section
[options]
-dependency_links =
python_requires = >= 3.6.1
related projects
- setup-py-upgrade: automatically migrate
setup.py->setup.cfg
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file setup_cfg_fmt-3.2.0.tar.gz.
File metadata
- Download URL: setup_cfg_fmt-3.2.0.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab2e179f8d5e5fd62d9574d4ce662dcce249ce2461d09e13931c963d8fe74721
|
|
| MD5 |
490fb6d8d681de5ed094ba8baf0b6344
|
|
| BLAKE2b-256 |
280137784cd555351c16e888b795f7b61777245425edd253f264e4510e993e3e
|
File details
Details for the file setup_cfg_fmt-3.2.0-py2.py3-none-any.whl.
File metadata
- Download URL: setup_cfg_fmt-3.2.0-py2.py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e4a9472a0ec388404505d40367474c8e43f51c248a98263314b9e71fc88bcb9
|
|
| MD5 |
2b3a99dcdfb36244a4e4388cfa1a8280
|
|
| BLAKE2b-256 |
b33516fcee9465ff69115bf18d6f071949d7848d565ac07fe60e475eab3d3271
|