gpt4 book ai didi

python - pyproject.toml中 "[tool.setuptools.packages] find = {}"的作用

转载 作者:行者123 更新时间:2023-12-05 03:17:08 33 4
gpt4 key购买 nike

GitLab 用于为包注册表打包 Python 项目的说明指导用户创建一个包含以下内容的 pyproject.toml 文件:

[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "mypypipackage"
version = "0.0.1"
authors = [
{ name="Example Author", email="author@example.com" },
]
description = "A small example package"
requires-python = ">=3.7"
classifiers = [
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
]

[tool.setuptools.packages]
find = {}

谁能解释一下底部部分的 find = {} 的功能是什么? GitLab 指南没有解释,我似乎找不到任何相关文档。

.toml 文件当然按照说明工作得很好,但它似乎也可以在完全不包含 [tool.setuptools.packages] 部分的情况下工作。

最佳答案

这是一个setuptools custom discovery directive ,这里使用 pyproject.toml 语法。

If the automatic discovery does not work for you (e.g., you want to include in the distribution top-level packages with reserved names such as tasks, example or docs, or you want to exclude nested packages that would be otherwise included), you can use the provided tools for package discovery

[tool.setuptools.packages]
find = {} # Scanning implicit namespaces is active by default
# OR
find = {namespaces = false} # Disable implicit namespaces

find: (find_packages() or find = {}) takes a source directory and two lists of package name patterns to exclude and include, and then returns a list of str representing the packages it could find.

关于python - pyproject.toml中 "[tool.setuptools.packages] find = {}"的作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74284075/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com