pip緩存下載自http鏈接的包
你可能已經(jīng)注意到了, pip是不會(huì)緩存下載自http鏈接的package至本地緩存的, 原因是這樣的:
# We want to _only_ cache responses on securely fetched origins. We do
# this because we can't validate the response of an insecurely fetched
# origin, and we don't want someone to be able to poison the cache and
# require manual evication from the cache to fix it.
來自不安全鏈接包, 同樣被認(rèn)為是不安全的, 所以不被緩存.
緩存下載自HTTP鏈接的包
打開pip的項(xiàng)目代碼, 修改項(xiàng)目根目錄下的download.py
class PipSession(requests.Session):
timeout = None
def __init__(self, *args, **kwargs):
...
self.mount("https://", secure_adapter)
>>>>>>>定位到這里<<<<<<<<
將http鏈接對(duì)應(yīng)的adapter修改為secure_adapter
# self.mount("http://", insecure_adapter)
self.mount("http://", secure_adapter)
接下來就可以愉快的緩存啦
(:з」∠)