使用 Click 模块对 setuptools "name" 关键字参数感到困惑

Confused by setuptools "name" keyword parameter using Click module

我对 Click 模块示例中给出的设置工具关键字参数name感到困惑。

我没有在 Setuptools Documentation. The first mention under Basic Use gives no account, and only New and Changed keywords 中找到任何对 name 关键字参数的明确引用。

Dynamic Discovery of Services and Plugins 描述了入口点语法,但只提供了这些关系定义:

The entry_points argument to setup() accepts either a string with .ini-style sections, or a dictionary mapping entry point group names to either strings or lists of strings containing entry point specifiers. An entry point specifier consists of a name and value, separated by an = sign. The value consists of a dotted module name, optionally followed by a : and a dotted identifier naming an object within the module. [My emphasis]

此描述未提及 name 关键字参数——它们是否未连接?

Click Docs 中的第一个示例使 name 看起来是 模块名称 (其中 'module' 只是您的单个 .py 文件,即 yourscript.py),

setup(
    name='yourscript',
    [...stuff...]
    py_modules=['yourscript'],
    [...]
    entry_points='''
        [console_scripts]
        yourscript=yourscript:cli
    ''',

第二个示例的命名建议名称是 包名称(即 'module' 的父目录,其中模块是文件主机)。

setup(
    name='yourpackage',
    entry_points='''
        [console_scripts]
        yourscript=yourpackage.scripts.yourscript:cli
    ''',
)

确实有两个 "name" 我不确定的论点

我不明白这些参数是否与您代码中的元素有关,或者只存在于 setup.py(和相关的 pip 文件)中。并且,Entry Point 值是否指的是 Setup 值?

setup(name='…') 命名您的 软件包 。 IE。如果您使用 python setup.py sdistpython setup.py bdist_eggpython setup.py bdist_wheel 创建源代码或二进制包,您将拥有 $name-$version.tar.gz$name-$version.egg $name-$version.whl 文件。如果您使用 twine upload 上传文件,它们将被上传到 https://pypi.python.org/pypi/$name/$version.

包名通常与包含代码的目录名相同,并且几乎总是与模块名相同,但这不是必需的。我有一个包裹 Cheetah3, but its module name is Cheetah.

不同于包名 entry_points与你的代码有关。它们是代码中的可执行条目。由于它们是在运行时执行的,因此它们当然包含 模块 的名称。他们与 package.

没有任何关系

看例子:

/yourpackage/ <- this is the top-level directory; can be any
                 not necessary the same as package or module
    /yourmodule/ <- this is the top-level module directory;
                    it's what you use in `import yourmodule`
    /setup.py