我希望pip
从我的驾驶室安装车轮,然后回退到PyPI(通过高速缓存代理)当且仅当驾驶室缺少车轮时。
我试图通过调用
来实现这一目标pip install -U --index-url $PYPI_PROXY_URL --find-links $WHEELHOUSE_URL \
-r requirements.txt
然而,尽管驾驶室拥有所有必需的包裹,但它们来自它的地方似乎是非常随机的,它们来自它们,代理PyPI或驾驶室,而不是确定性。
我希望这是确定性的,并且总是首先选择驾驶室。如何使用pip
实现这一目标?
我知道--no-index
会迫使它只使用驾驶室,但我想保留对驾驶室中丢失的包裹进行后备的能力。
答案 0 :(得分:1)
深入研究pip的源代码我发现:
使用内部_candidate_sort_key
函数对有效候选项进行排序,其工作方式如下:
If not finding wheels, then sorted by version only. If finding wheels, then the sort order is by version, then: 1. existing installs 2. wheels ordered via Wheel.support_index_min(self.valid_tags) 3. source archives Note: it was considered to embed this logic into the Link comparison operators, but then different sdist links with the same version, would have to be considered equal
在其他条件相同的情况下,它会回退到hardcoded顺序,即:
从点子9.0.1开始,上面的顺序是硬编码的,因此无法使用设置或参数对其进行更改。