-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Description
Description of the problem / feature request / question:
All pkg_tar rules are failing to build on my machine that has python 3 as the default. The underlying code, such as tools/build_defs/pkg/archive.py, will only work with python 2. 2f552c3 set their srcs_version to PY2AND3 which seems like a mistake to me, since the code plainly doesn't work with python 3. You'll just get lots of this error:
Traceback (most recent call last):
File "/home/spxtr/.cache/bazel/_bazel_spxtr/3cc7cabe5adb3ad619705e438c90ee85/bazel-sandbox/d547a2c4-3483-4928-807b-357310eba411-1/execroot/bazel/bazel-out/host/bin/tools/build_defs/pkg/build_tar.runfiles/io_bazel/tools/build_defs/pkg/build_tar.py", line 22, in <module>
from tools.build_defs.pkg import archive
File "/home/spxtr/.cache/bazel/_bazel_spxtr/3cc7cabe5adb3ad619705e438c90ee85/bazel-sandbox/d547a2c4-3483-4928-807b-357310eba411-1/execroot/bazel/bazel-out/host/bin/tools/build_defs/pkg/build_tar.runfiles/io_bazel/tools/build_defs/pkg/archive.py", line 17, in <module>
from StringIO import StringIO
ModuleNotFoundError: No module named 'StringIO'
It's pretty straightforward to make tools/build_defs/pkg/*.py happy with python 3, but I'm not sure how to bump third_party/py/gflags. Evidently newer versions of that library are compatible with both.
Apologies if I'm missing something obvious. I've tried fiddling with various srcs_versions and --force_pythons but nothing is making it work out.
If possible, provide a minimal example to reproduce the problem:
bazel test //tools/build_defs/pkg:build_test
Environment info
- Operating System:
Arch Linux, which has python 3 as the default python. I have set --python2_path=python2 --python3_path=python and this is sufficient for most rules.
- Bazel version:
Master, which is 2202109 right now.
Relevant issue:
#1580 (comment) mentions that it is python 2 only. I can copy this info to that issue if this is too much of a dupe.
I'd be happy to work on a patch for this, but I'd appreciate some direction.