将依赖项添加到 [tool.poetry.extras]

发布于 2025-01-20 06:48:04 字数 908 浏览 2 评论 0原文

我需要将依赖项添加到我的软件包的额外依赖项中,而不是我依赖的软件包。
但是到处都可以描述如何通过其附加功能将软件包添加到我的依赖项中(例如文档或 )

这个问题 > pyproject.toml 内容:

[tool.poetry]
name = "my_project"

[tool.poetry.dependencies]
python = ">=3.8"
PyYAML = {version = "^6.0", optional = true}
matplotlib = {version = "^3.5.1", optional = true}

[tool.poetry.extras]
my_extras = ["PyYAML"]

以前我只是手动编辑pyproject.toml,但是现在,这些额外的套件被传播到poetry.lock.lock,因此,如果我这样做它只是在pyproject.toml中,我从诗歌获得警告,即我的锁定文件和pyproject文件未同步。 (当然,我可以同时编辑它们,但这是一种肮脏的方式)

matplotlib <代码> my_extras 添加的命令是什么?

I need to add dependencies to extra dependencies of my package, not packages that I depend on.
But everywhere it's described how to add package to my dependencies with their extras (e.g. documentation or this question)

My pyproject.toml contents:

[tool.poetry]
name = "my_project"

[tool.poetry.dependencies]
python = ">=3.8"
PyYAML = {version = "^6.0", optional = true}
matplotlib = {version = "^3.5.1", optional = true}

[tool.poetry.extras]
my_extras = ["PyYAML"]

Previously I just manually edited pyproject.toml, but now these bundles of extras are propagated to poetry.lock, so if I do it just in pyproject.toml I get warning from poetry that my lock file and pyproject file are not synchronised. (Of course I can edit them simultaneously, but it's a dirty way)

What is the command to add matplotlib to my_extras?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冬天旳寂寞 2025-01-27 06:48:05

目前没有命令可以将依赖项添加到额外的组中。您必须手动编辑pyproject.toml并随后运行poetry lock --no-update

At the moment there is no command to add a dependency to an extra group. You have to manual edit the pyproject.toml and run poetry lock --no-update afterwards.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文