setup-cfg-fmt


Namesetup-cfg-fmt JSON
Version 2.5.0 PyPI version JSON
download
home_pagehttps://github.com/asottile/setup-cfg-fmt
Summaryapply a consistent format to `setup.cfg` files
upload_time2023-10-02 22:16:58
maintainer
docs_urlNone
authorAnthony Sottile
requires_python>=3.8
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: v2.5.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 (currently defaulting to `3.11`)
- `--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": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "",
    "author": "Anthony Sottile",
    "author_email": "asottile@umich.edu",
    "download_url": "https://files.pythonhosted.org/packages/11/84/cf83c14d93cf5cdf97b6601d9b6a2988e266dd9bc35db2074bb45c7e8816/setup_cfg_fmt-2.5.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.5.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 (currently defaulting to `3.11`)\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\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.5.0",
    "project_urls": {
        "Homepage": "https://github.com/asottile/setup-cfg-fmt"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8584f555788e3b71f8e9a309afc37fc234569661e47c90d973c84ddb279a80cb",
                "md5": "d66ed36575e435d9ba8ba2c7b6c2346f",
                "sha256": "631dc66dd799f8177f56cf3c881779a166fea8cb34312baa2f01e32686d27840"
            },
            "downloads": -1,
            "filename": "setup_cfg_fmt-2.5.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d66ed36575e435d9ba8ba2c7b6c2346f",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.8",
            "size": 8697,
            "upload_time": "2023-10-02T22:16:57",
            "upload_time_iso_8601": "2023-10-02T22:16:57.341229Z",
            "url": "https://files.pythonhosted.org/packages/85/84/f555788e3b71f8e9a309afc37fc234569661e47c90d973c84ddb279a80cb/setup_cfg_fmt-2.5.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1184cf83c14d93cf5cdf97b6601d9b6a2988e266dd9bc35db2074bb45c7e8816",
                "md5": "7f7ceeff1fecf71f13c924971ba0dcbb",
                "sha256": "95d2f87cc77ec763d0de5127f03a274127cc3f458ca46bd9d644ada71d115f58"
            },
            "downloads": -1,
            "filename": "setup_cfg_fmt-2.5.0.tar.gz",
            "has_sig": false,
            "md5_digest": "7f7ceeff1fecf71f13c924971ba0dcbb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 8162,
            "upload_time": "2023-10-02T22:16:58",
            "upload_time_iso_8601": "2023-10-02T22:16:58.826612Z",
            "url": "https://files.pythonhosted.org/packages/11/84/cf83c14d93cf5cdf97b6601d9b6a2988e266dd9bc35db2074bb45c7e8816/setup_cfg_fmt-2.5.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-02 22:16:58",
    "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: 0.16305s