|
| 1 | +# setuptools-py2cfg |
| 2 | + |
| 3 | +<p> |
| 4 | + <a href="https://pypi.python.org/pypi/setuptools-py2cfg"><img alt="pypi version" src="https://img.shields.io/pypi/v/setuptools-py2cfg.svg"></a> |
| 5 | + <a href="https://github.com/gvalkov/setuptools-py2cfg/actions/workflows/tests.yml?query=branch:main"><img alt="Build status" src="https://img.shields.io/github/actions/workflow/status/gvalkov/setuptools-py2cfg/tests.yml?branch=main"></a> |
| 6 | + <a href="https://github.com/gvalkov/setuptools-py2cfg/blob/main/LICENSE.txt"><img alt="License" src="https://img.shields.io/pypi/l/setuptools-py2cfg"></a> |
| 7 | +</p> |
| 8 | + |
| 9 | + |
| 10 | +Since version 30.3.0, [setuptools supports] declarative configuration through |
| 11 | +the `setup.cfg` file. This script helps convert existing `setup.py` files to |
| 12 | +`setup.cfg` in the format expected by setuptools. |
| 13 | + |
| 14 | +A `setup.cfg` file may be migrated to `pyproject.toml` with the help of |
| 15 | +[`ini2toml`](https://pypi.org/project/ini2toml) and |
| 16 | +[`validate-pyproject`](https://github.com/abravalheri/validate-pyproject). |
| 17 | + |
| 18 | + |
| 19 | +## Usage |
| 20 | + |
| 21 | +Just point `setuptools-py2cfg` to a `setup.py` file or run it in a directory |
| 22 | +containing `setup.py`. For example, given the following `setup.py`: |
| 23 | + |
| 24 | +``` python |
| 25 | +from setuptools import setup, find_packages |
| 26 | + |
| 27 | +classifiers = [ |
| 28 | + 'Development Status :: 5 - Production/Stable', |
| 29 | + 'Programming Language :: Python :: 2.7', |
| 30 | + 'Programming Language :: Python :: 3', |
| 31 | + 'Programming Language :: Python :: 3.3', |
| 32 | + 'Programming Language :: Python :: 3.4', |
| 33 | + 'Programming Language :: Python :: 3.5', |
| 34 | + 'Programming Language :: Python :: 3.6', |
| 35 | + 'Intended Audience :: Developers', |
| 36 | + 'Topic :: Software Development :: Libraries', |
| 37 | + 'License :: OSI Approved :: BSD License', |
| 38 | +] |
| 39 | + |
| 40 | +extras_require = { |
| 41 | + 'tests': [ |
| 42 | + 'tox >= 2.6.0', |
| 43 | + 'pytest >= 3.0.3', |
| 44 | + ], |
| 45 | + 'devel': [ |
| 46 | + 'check-manifest >= 0.35', |
| 47 | + 'readme-renderer >= 16.0', |
| 48 | + ] |
| 49 | +} |
| 50 | + |
| 51 | +kw = { |
| 52 | + 'name': 'ansimarkup', |
| 53 | + 'version': '1.3.0', |
| 54 | + |
| 55 | + 'description': 'Produce colored terminal text with an xml-like markup', |
| 56 | + 'long_description': open('README.rst').read(), |
| 57 | + |
| 58 | + 'author': 'Georgi Valkov', |
| 59 | + 'author_email': '[email protected]', |
| 60 | + 'license': 'Revised BSD License', |
| 61 | + 'keywords': 'ansi terminal markup', |
| 62 | + 'url': 'https://github.com/gvalkov/python-ansimarkup', |
| 63 | + 'classifiers': classifiers, |
| 64 | + 'install_requires': 'colorama', |
| 65 | + 'extras_require': extras_require, |
| 66 | + 'packages': find_packages(), |
| 67 | + 'zip_safe': True, |
| 68 | +} |
| 69 | + |
| 70 | +if __name__ == '__main__': |
| 71 | + setup(**kw) |
| 72 | +``` |
| 73 | + |
| 74 | +Running `setuptools-py2cfg.py` would print: |
| 75 | + |
| 76 | +``` ini |
| 77 | +[metadata] |
| 78 | +name = ansimarkup |
| 79 | +version = 1.3.0 |
| 80 | +author = Georgi Valkov |
| 81 | + |
| 82 | +license = Revised BSD License |
| 83 | +description = Produce colored terminal text with an xml-like markup |
| 84 | +keywords = ansi, terminal, markup |
| 85 | +url = https://github.com/gvalkov/python-ansimarkup |
| 86 | +long_description = file: README.rst |
| 87 | +classifiers = |
| 88 | + Development Status :: 5 - Production/Stable |
| 89 | + Programming Language :: Python :: 2.7 |
| 90 | + Programming Language :: Python :: 3 |
| 91 | + Programming Language :: Python :: 3.3 |
| 92 | + Programming Language :: Python :: 3.4 |
| 93 | + Programming Language :: Python :: 3.5 |
| 94 | + Programming Language :: Python :: 3.6 |
| 95 | + Intended Audience :: Developers |
| 96 | + Topic :: Software Development :: Libraries |
| 97 | + License :: OSI Approved :: BSD License |
| 98 | + |
| 99 | +[options] |
| 100 | +packages = find: |
| 101 | +zip_safe = True |
| 102 | +install_requires = colorama |
| 103 | + |
| 104 | +[options.extras_require] |
| 105 | +tests = |
| 106 | + tox >= 2.6.0 |
| 107 | + pytest >= 3.0.3 |
| 108 | +devel = |
| 109 | + check-manifest >= 0.35 |
| 110 | + readme-renderer >= 16.0 |
| 111 | +``` |
| 112 | + |
| 113 | +There are several non-essential options that control the format of the |
| 114 | +generated ini-file: |
| 115 | + |
| 116 | + usage: setuptools-py2cfg.py [-h] [-t int] [-i int] [-a] [path] |
| 117 | + |
| 118 | + converts an existing setup.py file to a setup.cfg in the format expected by |
| 119 | + setuptools |
| 120 | + |
| 121 | + positional arguments: |
| 122 | + path path to setup.py file (default: ./setup.py) |
| 123 | + |
| 124 | + optional arguments: |
| 125 | + -h, --help show this help message and exit |
| 126 | + -t int, --dangling-list-threshold int |
| 127 | + lists longer than this many characters are converted |
| 128 | + to a dangling list (default: 40) |
| 129 | + -i int, --dangling-list-indent int |
| 130 | + number of spaces to use when indenting dangling lists |
| 131 | + (default: 4) |
| 132 | + -a, --always-use-dangling-lists |
| 133 | + use dangling lists everywhere (default: False) |
| 134 | + |
| 135 | +Keep in mind that a `setup.py` file with a single call to `setuptools.setup()` |
| 136 | +is still needed after migrating all metadata to `setup.cfg`. |
| 137 | + |
| 138 | +## Installation |
| 139 | + |
| 140 | +The latest stable version of setuptools-py2cfg can be installed from |
| 141 | +pypi: |
| 142 | + |
| 143 | +``` bash |
| 144 | +$ pip install setuptools-py2cfg |
| 145 | +``` |
| 146 | + |
| 147 | +## Todo |
| 148 | + |
| 149 | +- Handle `entry_scripts` in ini-format. |
| 150 | +- Write a test or two. |
| 151 | + |
| 152 | +## License |
| 153 | + |
| 154 | +Released under the terms of the [Revised BSD License]. |
| 155 | + |
| 156 | + [setuptools supports]: https://setuptools.readthedocs.io/en/latest/userguide/declarative_config.html |
| 157 | + [Revised BSD License]: https://raw.github.com/gvalkov/setuptools-py2cfg/master/LICENSE |
0 commit comments