pip如何判断多个依赖的依赖版本
How does PIP determine the version of a dependency of multiple dependents
假设我们在 Python 中有以下依赖关系树,使用 PIP 作为包安装程序:
A==1.2.1:
| - B==1.5.4
| - C==?.?.?
D==1.3.0:
| - C==?.?.?
我们还假设软件包 C
的现有版本如下:
- 0.0.8
- 1.0.2
正如我们所知,PIP 不会将同一包的不同版本安装到一个环境中。这意味着它必须为所有家属选择一个合适的版本。
我简直无法理解PIP如何确定合适的版本。
如果包 A
依赖于 C==0.0.8
而包 D
依赖于 C==1.0.2
,这种情况不容易处理,不像其他包管理器,如 [=19] =] 可以做到。
When pip installs a package, it automatically installs any dependent Python packages without checking if these conflict with previously installed packages. It will install a package and any of its dependencies regardless of the state of the existing installation. Because of this, a user with a working installation of, for example, Google Tensorflow, can find that it stops working having used pip to install a different package that requires a different version of the dependent NumPy library than the one used by Tensorflow. In some cases, the package may appear to work but produce different results in detail.
关于这个话题,事情很快就会发生变化。由于 pip 的开发人员目前正在开发新的 依赖解析器 :
今天要对其进行测试,您可能需要安装 pip 20.2b1 并启用 不稳定功能 "解析器",例如以下之一:
PIP_UNSTABLE_FEATURE=resolver python -m pip install SomeProject
python -m pip --unstable-feature=resolver install SomeProject
有关详细信息,请参阅以下内容link:
其他参考资料:
- http://www.ei8fdb.org/thoughts/2020/05/test-pips-alpha-resolver-and-help-us-document-dependency-conflicts/
- https://pradyunsg.me/blog/2020/03/27/pip-resolver-testing/
- https://www.pythonpodcast.com/pip-resolver-dependency-management-episode-264/
更新 pip 20.2
假设我们在 Python 中有以下依赖关系树,使用 PIP 作为包安装程序:
A==1.2.1:
| - B==1.5.4
| - C==?.?.?
D==1.3.0:
| - C==?.?.?
我们还假设软件包 C
的现有版本如下:
- 0.0.8
- 1.0.2
正如我们所知,PIP 不会将同一包的不同版本安装到一个环境中。这意味着它必须为所有家属选择一个合适的版本。
我简直无法理解PIP如何确定合适的版本。
如果包 A
依赖于 C==0.0.8
而包 D
依赖于 C==1.0.2
,这种情况不容易处理,不像其他包管理器,如 [=19] =] 可以做到。
When pip installs a package, it automatically installs any dependent Python packages without checking if these conflict with previously installed packages. It will install a package and any of its dependencies regardless of the state of the existing installation. Because of this, a user with a working installation of, for example, Google Tensorflow, can find that it stops working having used pip to install a different package that requires a different version of the dependent NumPy library than the one used by Tensorflow. In some cases, the package may appear to work but produce different results in detail.
关于这个话题,事情很快就会发生变化。由于 pip 的开发人员目前正在开发新的 依赖解析器 :
今天要对其进行测试,您可能需要安装 pip 20.2b1 并启用 不稳定功能 "解析器",例如以下之一:
PIP_UNSTABLE_FEATURE=resolver python -m pip install SomeProject
python -m pip --unstable-feature=resolver install SomeProject
有关详细信息,请参阅以下内容link:
其他参考资料:
- http://www.ei8fdb.org/thoughts/2020/05/test-pips-alpha-resolver-and-help-us-document-dependency-conflicts/
- https://pradyunsg.me/blog/2020/03/27/pip-resolver-testing/
- https://www.pythonpodcast.com/pip-resolver-dependency-management-episode-264/
更新 pip 20.2