Poetry 中的 deps 和 dev-deps 有什么区别?

What is the difference between deps and dev-deps in Poetry?

在Poetry的pyproject.toml配置文件中可以同时指定dependenciesdev-dependencies,但是文档没有明确说明是什么区别是

我从名字猜想 dev-dependencies 不会被发布版本安装,但我没有注意到任何区别。如何正确使用这些字段,例如在构建中排除 dev-dependencies?

你的假设是正确的。开发依赖项的最佳用例是在创建具有可选依赖项的库时。例如,您正在开发应该与 MySQL、PostgreSQL 等一起工作的 ORM。您必须测试您的代码是否与所有这些 RDBMS 一起工作。您将其放入开发依赖项中。但是对于安装你的库的人来说,这些依赖项是可选的,它们不会自动安装。

通常,用于测试或构建应用程序的所有库都在开发依赖项中提供。

How do you use these fields correctly, for example exclude the dev-dependencies in a build?

poetry install 有一个 no-dev 标志正是针对该场景。