setup-cfg-fmt


Namesetup-cfg-fmt JSON
Version 3.1.0 PyPI version JSON
download
home_pagehttps://github.com/asottile/setup-cfg-fmt
Summaryapply a consistent format to `setup.cfg` files
upload_time2025-10-09 20:36:43
maintainerNone
docs_urlNone
authorAnthony Sottile
requires_python>=3.9
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![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: v3.1.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` if `LICENSE` exists

```diff
 [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_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
+    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/8f/4e/fdd527fe538c0c553057b099af7b86a908ddb8eec7bdd06339d2a8f2c571/setup_cfg_fmt-3.1.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: v3.1.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` 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```\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+    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": "3.1.0",
    "project_urls": {
        "Homepage": "https://github.com/asottile/setup-cfg-fmt"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "e8e38ddee784ce9920de14b487b5faf8d182709e61135f0d9f82e414cc7c5ca5",
                "md5": "d300c3caec77f07abf1e0322e710d4bd",
                "sha256": "785e9c2619592bd41797fa8c514bb744f2206e32601cd45502ef351289330257"
            },
            "downloads": -1,
            "filename": "setup_cfg_fmt-3.1.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d300c3caec77f07abf1e0322e710d4bd",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.9",
            "size": 8010,
            "upload_time": "2025-10-09T20:36:42",
            "upload_time_iso_8601": "2025-10-09T20:36:42.959091Z",
            "url": "https://files.pythonhosted.org/packages/e8/e3/8ddee784ce9920de14b487b5faf8d182709e61135f0d9f82e414cc7c5ca5/setup_cfg_fmt-3.1.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "8f4efdd527fe538c0c553057b099af7b86a908ddb8eec7bdd06339d2a8f2c571",
                "md5": "29ce58442341abbaa4c4c0af1673d6eb",
                "sha256": "e566a17d34323b8a19b67b08516bad2b6e654f76b70d9bb6329b914290a8ce9d"
            },
            "downloads": -1,
            "filename": "setup_cfg_fmt-3.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "29ce58442341abbaa4c4c0af1673d6eb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 7521,
            "upload_time": "2025-10-09T20:36:43",
            "upload_time_iso_8601": "2025-10-09T20:36:43.701456Z",
            "url": "https://files.pythonhosted.org/packages/8f/4e/fdd527fe538c0c553057b099af7b86a908ddb8eec7bdd06339d2a8f2c571/setup_cfg_fmt-3.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-09 20:36:43",
    "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"
}
        
Elapsed time: 4.76764s