pip缓存下载自http链接的包
你可能已经注意到了, pip是不会缓存下载自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.
来自不安全链接包, 同样被认为是不安全的, 所以不被缓存.
缓存下载自HTTP链接的包
打开pip的项目代码, 修改项目根目录下的download.py
class PipSession(requests.Session):
timeout = None
def __init__(self, *args, **kwargs):
...
self.mount("https://", secure_adapter)
>>>>>>>定位到这里<<<<<<<<
将http链接对应的adapter修改为secure_adapter
# self.mount("http://", insecure_adapter)
self.mount("http://", secure_adapter)
接下来就可以愉快的缓存啦
(:з」∠)