Skip to main content

setuptools-py2cfg

pypi version Build status License

Since version 30.3.0, setuptools supports declarative configuration through the setup.cfg file. This script helps convert existing setup.py files to setup.cfg in the format expected by setuptools.

A setup.cfg file may be migrated to pyproject.toml with the help of ini2toml and validate-pyproject.

Usage

Just point setuptools-py2cfg to a setup.py file or run it in a directory containing setup.py. For example, given the following setup.py:

from setuptools import setup, find_packages

classifiers = [
    'Development Status :: 5 - Production/Stable',
    'Programming Language :: Python :: 2.7',
    'Programming Language :: Python :: 3',
    'Programming Language :: Python :: 3.3',
    'Programming Language :: Python :: 3.4',
    'Programming Language :: Python :: 3.5',
    'Programming Language :: Python :: 3.6',
    'Intended Audience :: Developers',
    'Topic :: Software Development :: Libraries',
    'License :: OSI Approved :: BSD License',
]

extras_require = {
    'tests': [
        'tox >= 2.6.0',
        'pytest >= 3.0.3',
    ],
    'devel': [
        'check-manifest >= 0.35',
        'readme-renderer >= 16.0',
    ]
}

kw = {
    'name':                 'ansimarkup',
    'version':              '1.3.0',

    'description':          'Produce colored terminal text with an xml-like markup',
    'long_description':     open('README.rst').read(),

    'author':               'Georgi Valkov',
    'author_email':         'georgi.t.valkov@gmail.com',
    'license':              'Revised BSD License',
    'keywords':             'ansi terminal markup',
    'url':                  'https://github.com/gvalkov/python-ansimarkup',
    'classifiers':          classifiers,
    'install_requires':     'colorama',
    'extras_require':       extras_require,
    'packages':             find_packages(),
    'zip_safe':             True,
}

if __name__ == '__main__':
    setup(**kw)

Running setuptools-py2cfg.py would print:

[metadata]
name = ansimarkup
version = 1.3.0
author = Georgi Valkov
author_email = georgi.t.valkov@gmail.com
license = Revised BSD License
description = Produce colored terminal text with an xml-like markup
keywords = ansi, terminal, markup
url = https://github.com/gvalkov/python-ansimarkup
long_description = file: README.rst
classifiers =
    Development Status :: 5 - Production/Stable
    Programming Language :: Python :: 2.7
    Programming Language :: Python :: 3
    Programming Language :: Python :: 3.3
    Programming Language :: Python :: 3.4
    Programming Language :: Python :: 3.5
    Programming Language :: Python :: 3.6
    Intended Audience :: Developers
    Topic :: Software Development :: Libraries
    License :: OSI Approved :: BSD License

[options]
packages = find:
zip_safe = True
install_requires = colorama

[options.extras_require]
tests =
    tox >= 2.6.0
    pytest >= 3.0.3
devel =
    check-manifest >= 0.35
    readme-renderer >= 16.0

There are several non-essential options that control the format of the generated ini-file:

usage: setuptools-py2cfg.py [-h] [-t int] [-i int] [-a] [path]

converts an existing setup.py file to a setup.cfg in the format expected by
setuptools

positional arguments:
  path                  path to setup.py file (default: ./setup.py)

optional arguments:
  -h, --help            show this help message and exit
  -t int, --dangling-list-threshold int
                        lists longer than this many characters are converted
                        to a dangling list (default: 40)
  -i int, --dangling-list-indent int
                        number of spaces to use when indenting dangling lists
                        (default: 4)
  -a, --always-use-dangling-lists
                        use dangling lists everywhere (default: False)

Keep in mind that a setup.py file with a single call to setuptools.setup() is still needed after migrating all metadata to setup.cfg.

Installation

The latest stable version of setuptools-py2cfg can be installed from pypi:

$ pip install setuptools-py2cfg

Todo

  • Handle entry_scripts in ini-format.
  • Write a test or two.

License

Released under the terms of the Revised BSD License.

Metadata

Release files for setuptools-py2cfg 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for setuptools-py2cfg 2.1.0
File Size Uploaded
setuptools_py2cfg-2.1.0.tar.gz 8.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for setuptools-py2cfg 2.1.0
File Interpreter ABI Platform
setuptools_py2cfg-2.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 15.7 kB

Release files / setuptools_py2cfg-2.1.0.tar.gz

Download URL setuptools_py2cfg-2.1.0.tar.gz
Size 8.0 kB
Tags Source
SHA-256 checksum
How to use checksums
5597700a809fc3ee07a7392d6fc1cd7ed2c083979e9d2bfcaab965eb607cef10
BLAKE2b-256 checksum
How to use checksums
07fc518f007a68573927bf014e9eba44ccebffa459a0a87dc4bf66b03e14896d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.5

Release files / setuptools_py2cfg-2.1.0-py3-none-any.whl

Download URL setuptools_py2cfg-2.1.0-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
74d9704fcf7a83fceb07f8ffc24830fd5343e6058393d2b66547fdfb7fe66845
BLAKE2b-256 checksum
How to use checksums
880c9cdcfbdbe442ee4526bf1166155e15141a1fd3c6393c0fdb402c13be8a40
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.5

Release history Release notifications | RSS feed

This release

2.1.0 This release

2 release files

2.0.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page