如何在setup.cfg中设置Entry_Points

2022-03-25 00:00:00 python python-3.x setuptools python-3.6

问题描述

我将配置从setup.py移动到setup.cfg,但设置entry_points参数时出现问题。不过,目前我使用的是一种有效的混合方法,我想将entry_points移到setup.cfg。

发件人

def setup_package():
    setup(version=get_version(),
          entry_points={'console_scripts':['app=my_package.app.run:cli'],})

[metadata]
name = my-package
description = my-package
license = unlicensed
long-description = README.md
platforms = any
classifiers =
  Programming Language :: Python

[options]
zip_safe = False
packages = my_package,  my_package.app
include_package_data = True
package_dir =
  = .
tests_require = pytest; pytest-cov

[entry_points]
console_scripts =
  my-package = my_package.app.run:cli

解决方案

节必须是[options.entry_points]。请参阅https://github.com/github/octodns/blob/4b44ab14b1f0a52f1051c67656d6e3dd6f0ba903/setup.cfg#L34

中的示例
[options.entry_points]
console_scripts =
    octodns-compare = octodns.cmds.compare:main
    octodns-dump = octodns.cmds.dump:main
    octodns-report = octodns.cmds.report:main
    octodns-sync = octodns.cmds.sync:main
    octodns-validate = octodns.cmds.validate:main

相关文章