PIP冻结可以显示可选依赖项(方括号)吗?

发布于 2025-02-07 18:18:13 字数 714 浏览 0 评论 0原文

我注意到,如果我安装了具有可选依赖项的软件包(setup.py extras_require):

$ pip install mypackage[optional]==1.0.0

我看不到pip freeze freeze freeze的输出中的可选依赖性:

$ pip freeze | grep mypackage
mypackage==1.0.0

但是,我正在使用一项要求 -冻结工作流程涉及使用pip Freeze以我在生产中使用的精确版本更新需求文件。那么,我想看到的是:

mypackage[optional]==1.0.0

有没有办法实现这一目标?

更新: 有人向我指出,我实际上在冻结工作流程中不需要这一点。在该工作流程(至少我正在使用的版本)中,您首先运行pip install -r需求to-freeze.txt,它具有mypackage [option]。这将找到最新版本,并安装可选依赖项。稍后,当运行pip冻结时,可选依赖项将在列表中。因此,实际上,mypackage出现在pip Freeze的情况下,没有方括号表示法是可以的。预期的结果仍然可以实现。

I notice that if I install a package with optional dependencies (setup.py extras_require):

$ pip install mypackage[optional]==1.0.0

I do not see the optional dependency in the output of pip freeze:

$ pip freeze | grep mypackage
mypackage==1.0.0

However, I'm using a requirements-to-freeze workflow that involves using pip freeze to update the requirements file with exact versions I use in production. So, what I would like to see is:

mypackage[optional]==1.0.0

Is there a way to achieve this?

Update:
Someone pointed out to me that I actually don't need this in the requirements-to-freeze workflow. In that workflow (at least the version I'm using), you first run pip install -r requirements-to-freeze.txt, which has mypackage[option]. This will find the latest version and also install the optional dependencies. Later, when pip freeze is run, the optional dependencies will be in the list. So actually, the fact that mypackage shows up in pip freeze without the square bracket notation is fine. The desired outcome will still be achieved.

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

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

发布评论

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

评论(1

一口甜 2025-02-14 18:18:13

根据pip冻结文档事物

According to the pip freeze documentation, there is no option to do such that thing

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