-
-
Notifications
You must be signed in to change notification settings - Fork 650
Description
🐞 bug report
Affected Rule
The issue is caused by the rule:pip_install()
Is this a regression?
Yes. It does not occur with rules_python 0.6.0, but does occur on 0.8.0.
I found the commit that broke it (see below), so I can say it doesn't affect 0.7.0.
Description
I upgraded rules_python to 0.8.0 and ran into wheel install failure that dumps FileExistsError: [Errno 17] File exists: 'pypi__gast'
I don't have gast in my requirements.txt, but after some binary searching I tracked it down to tensorflow==2.8.0 (intel) or 2.7.0 (arm64). I replaced my requirements.txt with just the dependencies of tensorflow, but not tensorflow itself, and it works. Just tensorflow by itself causes the failure, so it seems to be related to interaction between the tensorflow wheel and the gast wheel.
I ended up testing 2 tensorflow versions while tracking this down:
- tensorflow 2.8.0 + gast 0.5.3 (x86)
- tensorflow 2.7.0 + gast 0.4.0 (arm64)
🔬 Minimal Reproduction
Make a stub repo, then bazel build //...
cat > WORKSPACE << "EOF"
workspace(name = "required")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "rules_python",
sha256 = "9fcf91dbcc31fde6d1edb15f117246d912c33c36f44cf681976bd886538deba6",
strip_prefix = "rules_python-0.8.0",
url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/0.8.0.tar.gz",
)
load("@rules_python//python:repositories.bzl", "python_register_toolchains")
python_register_toolchains(
name = "python39",
python_version = "3.9",
)
load("@python39//:defs.bzl", "interpreter")
load("@rules_python//python:pip.bzl", "pip_install")
pip_install(
name = "common_deps",
python_interpreter_target = interpreter,
requirements = "//:requirements.txt",
)
EOF
cat > requirements.txt << "EOF"
tensorflow
EOF
cat > BUILD << "EOF"
load("@common_deps//:requirements.bzl", "requirement")
load("@rules_python//python:defs.bzl", "py_binary")
py_binary(
name = "hello",
srcs = ["hello.py"],
deps = [requirement("tensorflow")],
)
EOFIf you git bisect between 0.6.0 and 0.8.0 rules_python releases, it breaks at commit fe30f15 (PR #661)
If you pare it down to just a change to python/pip_install/repositories.bzl, and binary search on the package upgrades in the file, it's specifically broken by the upgrade of pkginfo from 1.7.1 to 1.8.2.
🔥 Exception or Error
(Traceback (most recent call last):
File "/home/builder/.cache/bazel/_bazel_laz/99bd544777c52d5a0d8a66ea3b05626a/external/python3_aarch64-unknown-linux-gnu/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/home/builder/.cache/bazel/_bazel_laz/99bd544777c52d5a0d8a66ea3b05626a/external/python3_aarch64-unknown-linux-gnu/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/home/builder/.cache/bazel/_bazel_laz/99bd544777c52d5a0d8a66ea3b05626a/external/rules_python/python/pip_install/extract_wheels/__main__.py", line 5, in <module>
main()
File "/home/builder/.cache/bazel/_bazel_laz/99bd544777c52d5a0d8a66ea3b05626a/external/rules_python/python/pip_install/extract_wheels/__init__.py", line 110, in main
targets = [
File "/home/builder/.cache/bazel/_bazel_laz/99bd544777c52d5a0d8a66ea3b05626a/external/rules_python/python/pip_install/extract_wheels/__init__.py", line 113, in <listcomp>
bazel.extract_wheel(
File "/home/builder/.cache/bazel/_bazel_laz/99bd544777c52d5a0d8a66ea3b05626a/external/rules_python/python/pip_install/extract_wheels/lib/bazel.py", line 377, in extract_wheel
os.mkdir(directory)
FileExistsError: [Errno 17] File exists: 'pypi__gast'
)
🌍 Your Environment
Operating System:
Played with this across Linux x86, OSX aarch64, Linux arm64
Output of bazel version:
% bazel version
Bazelisk version: v1.5.0
Build label: 4.2.2
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Thu Dec 2 18:15:58 2021 (1638468958)
Build timestamp: 1638468958
Build timestamp as int: 1638468958but in testing the test repo above, it fetches:
% bazel version
Bazelisk version: v1.5.0
Build label: 5.0.0
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Wed Jan 19 14:08:54 2022 (1642601334)
Build timestamp: 1642601334
Build timestamp as int: 1642601334Rules_python version:
0.8.0
Anything else relevant?
Can be hacked around with this patch applied to 0.8.0 of rules_python:
diff --git a/python/pip_install/repositories.bzl b/python/pip_install/repositories.bzl
index 352f663..22e9e37 100644
--- a/python/pip_install/repositories.bzl
+++ b/python/pip_install/repositories.bzl
@@ -29,8 +29,8 @@ _RULE_DEPS = [
),
(
"pypi__pkginfo",
- "https://files.pythonhosted.org/packages/cd/00/49f59cdd2c6a52e6665fda4de671dac5614366dc827e050c55428241b929/pkginfo-1.8.2-py2.py3-none-any.whl",
- "c24c487c6a7f72c66e816ab1796b96ac6c3d14d49338293d2141664330b55ffc",
+ "https://files.pythonhosted.org/packages/77/83/1ef010f7c4563e218854809c0dff9548de65ebec930921dedf6ee5981f27/pkginfo-1.7.1-py2.py3-none-any.whl",
+ "37ecd857b47e5f55949c41ed061eb51a0bee97a87c969219d144c0e023982779",
),
(
"pypi__setuptools",