rules_pip
rules_pip copied to clipboard
Bazel build fails due to bad pip cache
Environments can get into a bad state by interrupted pip installs or other corruption of the pip wheel, which leads to all subsequent builds failing with errors similar to:
File "/home/buildkite-agent/.cache/bazel/_bazel_buildkite-agent/f1d1ae8a5075539a72e45ef6b412b203/external/com_github_ali5h_rules_pip/third_party/py/pip/_internal/metadata/base.py", line 321, in as_zipfile
--
| return zipfile.ZipFile(self.location, allowZip64=True)
| File "/usr/lib/python3.8/zipfile.py", line 1269, in __init__
| self._RealGetContents()
| File "/usr/lib/python3.8/zipfile.py", line 1336, in _RealGetContents
| raise BadZipFile("File is not a zip file")
| zipfile.BadZipFile: File is not a zip file
| Traceback (most recent call last):
| File "/home/buildkite-agent/.cache/bazel/_bazel_buildkite-agent/f1d1ae8a5075539a72e45ef6b412b203/external/com_github_ali5h_rules_pip/src/whl.py", line 401, in <module>
| main()
| File "/home/buildkite-agent/.cache/bazel/_bazel_buildkite-agent/f1d1ae8a5075539a72e45ef6b412b203/external/com_github_ali5h_rules_pip/src/whl.py", line 262, in main
| pkg = install_package(args.package, args.directory, pip_args)
| File "/home/buildkite-agent/.cache/bazel/_bazel_buildkite-agent/f1d1ae8a5075539a72e45ef6b412b203/external/com_github_ali5h_rules_pip/src/whl.py", line 108, in install_package
| dist_info = glob.glob(os.path.join(directory, "*.dist-info"))[0]
| IndexError: list index out of range
| )
Internally we've wrapped the pip install with a retry and removal of the package from the local pip cache; wanted to see if there was interest in having the change upstreamed. @ali5h
yeah, that would be great