2017-03-07 40 views
0

我想pip从我的驾驶室安装车轮,并(通过高速缓存代理)退回到PyPI中当且仅当车轮从驾驶室缺失。什么决定了哪个索引`pip`要使用?

我试图通过调用

pip install -U --index-url $PYPI_PROXY_URL --find-links $WHEELHOUSE_URL \ 
      -r requirements.txt 

然而,而不是被在那里得到的包确定性从它似乎在他们来自代理的PyPI或驾驶室来这里很随意实现这一点,尽管驾驶室有所有必需的包裹。

我想这是确定的,总是先选择驾驶室。我如何通过pip实现这一目标?

我知道--no-index将迫使它仅使用了驾驶室,但我想保留到回落的包从驾驶室缺少的能力。

+0

这是否帮助任何? http://stackoverflow.com/questions/30889494/can-pip-conf-specify-two-index-url-at-the-same-time – Randy31

+0

@ Randy31并不比其他谈论一个指标优先 – vartec

回答

1

挖掘到点子的源代码,我发现:

  1. 有效候选人都使用内部_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 
    
  2. 所有其他相同时,将回退到hardcoded顺序是:

    1. 本地文件系统
    2. 索引中的网址
    3. 发现链接网址
    4. 依赖链接网址

由于PIP的9.0.1上面的顺序是硬编码的,所以没有使用设置或参数更改它的方法。