【问题标题】:With a python requirements file can you control order of installing package dependencies?使用 python 需求文件,您可以控制安装包依赖项的顺序吗?
【发布时间】:2012-07-19 03:47:54
【问题描述】:

通常你会希望所有包都声明它们的依赖关系,但有时这是你无法控制的,对于大型或复杂的包来说,“fork it”并不容易。

例如,SciPi 需要 NumPy,但没有指定它。那么对于你无法控制的包,有没有办法告诉 setup.py 或 pip 按特定顺序安装?

【问题讨论】:

  • 答案可能有点令人失望:stackoverflow.com/questions/5394356/…
  • 是 SciPi 需要 NumPy 还是 SciPi 安装过程需要 NuymPy?如果是第一个,您可以按任何顺序安全地安装。

标签: python scipy pip setup.py


【解决方案1】:

4/13/2015 更新:作为@Garrrett commented,pip v6.1.0 中的安装顺序行为发生了变化。取自pip v7.0.0.dev0 docs

从 v6.1.0 开始,pip 在依赖项之前安装依赖项,即按照“拓扑顺序”。这是目前唯一与订单相关的承诺点。虽然 pip 会按照安装参数的顺序或需求文件中项目的顺序安装东西可能是巧合,但这不是一个承诺。


初步答案(过时)

使用带有pip 的需求文件。由于 0.8.3 版本 pip 按照需求文件中列出的顺序安装包。

【讨论】:

  • 相关:Non-alphabetical installation of requirements pip 的 github 存储库中的错误。
  • 这个答案不正确。 As of v6.1.0, pip installs dependencies before their dependents, i.e. in "topological order". This is the only commitment pip currently makes related to order. While it may be coincidentally true that pip will install things in the order of the install arguments or in the order of the items in a requirements file, this is not a promise. (ref)
  • 这是一个新功能,@Garrett,感谢您的评论。如果您用新信息回答了 OP 的问题,并且 OP 将您的答案标记为正确,那就太好了。
猜你喜欢
  • 2011-06-27
  • 1970-01-01
  • 2021-03-03
  • 1970-01-01
  • 2015-06-28
  • 2012-05-07
  • 2018-12-30
  • 2018-07-25
  • 1970-01-01
相关资源
最近更新 更多