跳转到主要内容

将setuptools setup.py转换为setup.cfg

项目描述

setuptools-py2cfg

pypi version Build status License

自版本30.3.0起,setuptools支持 通过setup.cfg文件进行声明性配置。此脚本有助于将现有的setup.py文件转换为setuptools期望的格式的setup.cfg

可以使用ini2tomlvalidate-pyprojectsetup.cfg文件迁移到pyproject.toml

用法

只需将setuptools-py2cfg指向一个setup.py文件或在一个包含setup.py的目录中运行它。例如,给定以下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)

运行setuptools-py2cfg.py将打印

[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

有一些非必要选项可以控制生成的ini文件的格式

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)

请注意,在将所有元数据迁移到setup.cfg之后,仍然需要一个调用setuptools.setup()的单个setup.py文件。

安装

可以从pypi安装setuptools-py2cfg的最新稳定版本

$ pip install setuptools-py2cfg

待办事项

  • 处理ini格式的entry_scripts
  • 编写一个或两个测试。

许可证

修订版BSD许可证下发布。

项目详情


下载文件

下载适用于您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分布

setuptools_py2cfg-2.1.0.tar.gz (8.0 kB 查看哈希值)

上传时间:

构建分布

setuptools_py2cfg-2.1.0-py3-none-any.whl (7.7 kB 查看哈希值)

上传时间: Python 3

支持