首页 > 解决方案 > 使用 pip install --target 固定 git 修订的版本号

问题描述

我在单独的存储库中有两个 Python 项目,例如:commondepends_on_common.

由于我们部署环境的限制(我没有ssh访问权限),我希望使用

pip install --no-deps --target common /path/to/common

作为供应商的 CI/CD 构建阶段的common一部分depends_on_common。我想做的是指定一个显式版本的 common 或一个 git 修订版,而不是有效地始终构建快照。

文档中没有提到此功能:

-t, --target <dir>
  Install packages into <dir>. By default this will not replace existing files/folders in <dir>. Use --upgrade to replace existing packages in <dir> with new versions.

但我希望有一些聪明的方法来实现这一点。

标签: pythongitpipdependencies

解决方案


也许这部分pip install文档可以为您指明正确的方向。

你可能想要这样的东西:

pip install --no-deps --target ./common git+file:///path/to/common@da39a3ee5e6b4b0d3255bfef95601890afd80709#egg=common

推荐阅读