2017-03-07 39 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上面的順序是硬編碼的,所以沒有使用設置或參數更改它的方法。