我们如何强制 pip 对依赖项使用指定的包索引?

How can we force pip to use the specified package index for dependencies?

我们有一个自托管的 python 包索引。当我尝试通过

安装 cpplint
py -2 -m pip install cpplint -i ${self_hosted_package_index} --trusted-host ${self_host}

它成功地下载了 cpplint 包,但是无法从我的计算机被阻止的 https://files.pythonhosted.org/packages 下载 pytest_runner 包。结果,pip install失败了。

我先用运行py -2 -m pip install pytest_runner -i ${self_hosted_package_index} --trusted-host ${self_host}解决了问题

有没有办法强制pip install对所有涉及的包使用指定的索引?谢谢。

pytest-runnersetup_requires. setup_requires dependencies are installed using easy_install 中的 cpplintsetup.py 中声明为依赖项,它似乎不知道您的索引 URL;也许 pip 没有通过 URL.

所以不,在这种特殊情况下 (cpplint) 这是不可能的。对于大多数其他包,应该没问题。