我目前正在尝试在无法访问 PyPi 的计算机上自定义构建
envoy
。我公司的安全团队要求我们使用具有不同 URL 的公司代理来访问 PyPi 存储库。
当我尝试运行
bazel build ...
时,出现以下错误:
ERROR: An error occurred during the fetch of repository 'pypi__pip_tools':
Traceback (most recent call last):
File "/home/ubuntu/.cache/bazel/_bazel_ubuntu/b4e0fd0e207e6fdf5e33997b6741cf2d/external/bazel_tools/tools/build_defs/repo/http.bzl", line 132, column 45, in _http_archive_impl
download_info = ctx.download_and_extract(
Error in download_and_extract: java.io.IOException: Error downloading [https://files.pythonhosted.org/packages/0d/dc/38f4ce065e92c66f058ea7a368a9c5de4e702272b479c0992059f7693941/pip_tools-7.4.1-py3-none-any.whl] to /home/ubuntu/.cache/bazel/_bazel_ubuntu/b4e0fd0e207e6fdf5e33997b6741cf2d/external/pypi__pip_tools/temp12252431299166532778/pip_tools-7.4.1-py3-none-any.whl.zip: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
在这种情况下,安全错误是一个红鲱鱼,因为我需要用不同的域替换
https://files.pythonhosted.org
。
对于命令行
pip
,我必须执行以下操作:
python3 -m pip config set global.index-url <new_url_here>
是否有一些等效的方法可以强制
bazel
在获取Python工具时使用不同的域?
请注意,我已经看到了这个问题,但它没有帮助,因为这个错误是在进行任何
pip_install
调用之前作为安装 pip 本身过程的一部分发生的。
--experimental_downloader_config
标志。
例如:
rewrite ^(files.pythonhosted.org/.*) https://your.host/mirrors/$1
它将尝试在您的示例中获取文件:
https://files.pythonhosted.org/packages/0d/dc/38f4ce065e92c66f058ea7a368a9c5de4e702272b479c0992059f7693941/pip_tools-7.4.1-py3-none-any.whl
来自
https://https://your.host/mirrors/files.pythonhosted.org/packages/0d/dc/38f4ce065e92c66f058ea7a368a9c5de4e702272b479c0992059f7693941/pip_tools-7.4.1-py3-none-any.whl
相反。