[![build status](https://github.com/asottile/setup-cfg-fmt/actions/workflows/main.yml/badge.svg)](https://github.com/asottile/setup-cfg-fmt/actions/workflows/main.yml)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/asottile/setup-cfg-fmt/main.svg)](https://results.pre-commit.ci/latest/github/asottile/setup-cfg-fmt/main)
setup-cfg-fmt
=============
apply a consistent format to `setup.cfg` files
## installation
```bash
pip install setup-cfg-fmt
```
## as a pre-commit hook
See [pre-commit](https://github.com/pre-commit/pre-commit) for instructions
Sample `.pre-commit-config.yaml`:
```yaml
- repo: https://github.com/asottile/setup-cfg-fmt
rev: v2.7.0
hooks:
- id: setup-cfg-fmt
```
## cli
Consult the help for the latest usage:
```console
$ 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.
```diff
[metadata]
-version = 1.14.4
-name = pre_commit
+name = pre_commit
+version = 1.14.4
```
### normalizes dashes to underscores in project name
- `pip` will normalize names to dashes `foo_bar` => `foo-bar`
- `python setup.py sdist` produces a filename with the name verbatim
- `pip wheel .` produces a filename with an underscore-normalized name
```console
$ # 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.
```diff
[metadata]
-name = pre-commit
+name = pre_commit
```
### normalizes dashes to underscores in keys
setuptools allows dashed names but does not document them.
```diff
[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
```diff
[metadata]
name = pre_commit
version = 1.14.5
+long_description = file: README.md
+long_description_content_type = text/markdown
```
### adds `license_file` / `license` / license classifier if `LICENSE` exists
```diff
[metadata]
name = pre_commit
version = 1.14.5
+license = MIT
+license_file = LICENSE
+classifiers =
+ License :: OSI Approved :: MIT License
```
### set `python_requires`
A few sources are searched for guessing `python_requires`:
- the existing `python_requires` setting itself
- `envlist` in `tox.ini` if present
- python version `classifiers` that are already set
- the `--min-py-version` argument
### adds python version classifiers
classifiers are generated based on:
- the `python_requires` setting
- the `--max-py-version` argument
- `--include-version-classifiers` is specified
```diff
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:
```diff
name = pkg
version = 1.0
+classifiers =
+ Programming Language :: Python :: 3
```
### sorts classifiers
```diff
[metadata]
name = pre_commit
version = 1.14.5
classifiers =
- Programming Language :: Python :: 3
- License :: OSI Approved :: MIT License
+ License :: OSI Approved :: MIT License
+ Programming Language :: Python :: 3
Programming Language :: Python :: 3.6
```
### removes empty options in any section
```diff
[options]
-dependency_links =
python_requires = >= 3.6.1
```
## related projects
- [setup-py-upgrade]: automatically migrate `setup.py` -> `setup.cfg`
[setup-py-upgrade]: https://github.com/asottile/setup-py-upgrade
Raw data
{
"_id": null,
"home_page": "https://github.com/asottile/setup-cfg-fmt",
"name": "setup-cfg-fmt",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": null,
"author": "Anthony Sottile",
"author_email": "asottile@umich.edu",
"download_url": "https://files.pythonhosted.org/packages/ef/fc/54566121029234d6563ba3019793b4ccef6dd90b33a0c7b80f75c6442f37/setup_cfg_fmt-2.7.0.tar.gz",
"platform": null,
"description": "[![build status](https://github.com/asottile/setup-cfg-fmt/actions/workflows/main.yml/badge.svg)](https://github.com/asottile/setup-cfg-fmt/actions/workflows/main.yml)\n[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/asottile/setup-cfg-fmt/main.svg)](https://results.pre-commit.ci/latest/github/asottile/setup-cfg-fmt/main)\n\nsetup-cfg-fmt\n=============\n\napply a consistent format to `setup.cfg` files\n\n## installation\n\n```bash\npip install setup-cfg-fmt\n```\n\n## as a pre-commit hook\n\nSee [pre-commit](https://github.com/pre-commit/pre-commit) for instructions\n\nSample `.pre-commit-config.yaml`:\n\n```yaml\n- repo: https://github.com/asottile/setup-cfg-fmt\n rev: v2.7.0\n hooks:\n - id: setup-cfg-fmt\n```\n\n## cli\n\nConsult the help for the latest usage:\n\n```console\n$ setup-cfg-fmt --help\n```\n\n## what does it do?\n\n### sets a consistent ordering for attributes\n\nFor example, `name` and `version` (the most important metadata) will always\nappear at the top.\n\n```diff\n [metadata]\n-version = 1.14.4\n-name = pre_commit\n+name = pre_commit\n+version = 1.14.4\n```\n\n### normalizes dashes to underscores in project name\n\n- `pip` will normalize names to dashes `foo_bar` => `foo-bar`\n- `python setup.py sdist` produces a filename with the name verbatim\n- `pip wheel .` produces a filename with an underscore-normalized name\n\n```console\n$ # with dashed name\n$ python setup.py sdist && pip wheel -w dist .\n...\n$ ls dist/ | cat\nsetup_cfg_fmt-0.0.0-py2.py3-none-any.whl\nsetup-cfg-fmt-0.0.0.tar.gz\n$ # with underscore name\n$ python setup.py sdist && pip wheel -w dist .\n...\n$ ls dist/ | cat\nsetup_cfg_fmt-0.0.0-py2.py3-none-any.whl\nsetup_cfg_fmt-0.0.0.tar.gz\n```\n\nThis makes it easier to upload packages to pypi since they end up with the\nsame filename prefix.\n\n```diff\n [metadata]\n-name = pre-commit\n+name = pre_commit\n```\n\n### normalizes dashes to underscores in keys\n\nsetuptools allows dashed names but does not document them.\n\n```diff\n [metadata]\n name = pre-commit\n-long-description = file: README.md\n+long_description = file: README.md\n```\n\n### adds `long_description` if `README` is present\n\nThis will show up on the pypi project page\n\n```diff\n [metadata]\n name = pre_commit\n version = 1.14.5\n+long_description = file: README.md\n+long_description_content_type = text/markdown\n```\n\n### adds `license_file` / `license` / license classifier if `LICENSE` exists\n\n```diff\n [metadata]\n name = pre_commit\n version = 1.14.5\n+license = MIT\n+license_file = LICENSE\n+classifiers =\n+ License :: OSI Approved :: MIT License\n```\n\n### set `python_requires`\n\nA few sources are searched for guessing `python_requires`:\n\n- the existing `python_requires` setting itself\n- `envlist` in `tox.ini` if present\n- python version `classifiers` that are already set\n- the `--min-py-version` argument\n\n### adds python version classifiers\n\nclassifiers are generated based on:\n\n- the `python_requires` setting\n- the `--max-py-version` argument\n- `--include-version-classifiers` is specified\n\n```diff\n name = pkg\n version = 1.0\n+classifiers =\n+ Programming Language :: Python :: 3\n+ Programming Language :: Python :: 3.7\n+ Programming Language :: Python :: 3.8\n+ Programming Language :: Python :: 3.9\n+ Programming Language :: Python :: 3.10\n+ Programming Language :: Python :: 3.11\n+ ...\n```\n\nwithout `--include-version-classifiers` only the major version will be included:\n\n```diff\n name = pkg\n version = 1.0\n+classifiers =\n+ Programming Language :: Python :: 3\n```\n\n### sorts classifiers\n\n```diff\n [metadata]\n name = pre_commit\n version = 1.14.5\n classifiers =\n- Programming Language :: Python :: 3\n- License :: OSI Approved :: MIT License\n+ License :: OSI Approved :: MIT License\n+ Programming Language :: Python :: 3\n Programming Language :: Python :: 3.6\n```\n\n### removes empty options in any section\n\n```diff\n [options]\n-dependency_links =\n python_requires = >= 3.6.1\n```\n\n## related projects\n\n- [setup-py-upgrade]: automatically migrate `setup.py` -> `setup.cfg`\n\n[setup-py-upgrade]: https://github.com/asottile/setup-py-upgrade\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "apply a consistent format to `setup.cfg` files",
"version": "2.7.0",
"project_urls": {
"Homepage": "https://github.com/asottile/setup-cfg-fmt"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "37806b2043afde52b8bf0937ef06bf5bf64339082a01564cc60f3ccfd893e634",
"md5": "cbdf84264a155e138ebdceb92bc78f34",
"sha256": "22aebe129f512606b8b4b993d3bf88d483f8ba8ef8b861fb8b6feb6a9308af93"
},
"downloads": -1,
"filename": "setup_cfg_fmt-2.7.0-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "cbdf84264a155e138ebdceb92bc78f34",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": ">=3.9",
"size": 8666,
"upload_time": "2024-10-11T23:54:18",
"upload_time_iso_8601": "2024-10-11T23:54:18.828701Z",
"url": "https://files.pythonhosted.org/packages/37/80/6b2043afde52b8bf0937ef06bf5bf64339082a01564cc60f3ccfd893e634/setup_cfg_fmt-2.7.0-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "effc54566121029234d6563ba3019793b4ccef6dd90b33a0c7b80f75c6442f37",
"md5": "e23d629a59a8a6ab9c4b0788dae2777d",
"sha256": "398aef953144f96e8024db9ea90271f34ca375c97bb20f6624b83fa7e7a3d163"
},
"downloads": -1,
"filename": "setup_cfg_fmt-2.7.0.tar.gz",
"has_sig": false,
"md5_digest": "e23d629a59a8a6ab9c4b0788dae2777d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 8138,
"upload_time": "2024-10-11T23:54:19",
"upload_time_iso_8601": "2024-10-11T23:54:19.893685Z",
"url": "https://files.pythonhosted.org/packages/ef/fc/54566121029234d6563ba3019793b4ccef6dd90b33a0c7b80f75c6442f37/setup_cfg_fmt-2.7.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-11 23:54:19",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "asottile",
"github_project": "setup-cfg-fmt",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "setup-cfg-fmt"
}