Repository navigation
Description
There is not really any one place that I am aware of where any of this is documented, but long story short, Bazel is ever so slowly switching to a world where if you want init.py files, you should create them. The original (current) behavior is to have it auto-magically drop them everywhere. This breaks when you have namespace packages that span directories -- which is a normal way to distribute things.
The two flags at play are the global --incompatible_default_to_explicit_init_py and the py_binary/py_test attribute legacy_create_init = False. Unfortunately, the latter cannot be set on the internal version of bazel used at Google, making it next to impossible to have a sane default in a cross-project setup. We provide a special iree_py_test that sets it... and for mysterious reasons, it has stopped working.
The way to identify that this is happening is to look at the runfiles tree. For example:
cd ~/.cache/bazel/_bazel_stella/356fb9d2d6d75aff4619ed74d732c83e/execroot/iree_core/bazel-out/k8-opt/bin/integrations/tensorflow/e2e/math_test_manual.runfiles/iree_core && ls -R yield the following when correct:
.:
bindings external integrations
./bindings:
python
./bindings/python:
pyiree
./bindings/python/pyiree:
rt
./bindings/python/pyiree/rt:
binding.so __init__.py __pycache__ system_api.py
./bindings/python/pyiree/rt/__pycache__:
__init__.cpython-37.pyc system_api.cpython-37.pyc
./external:
bazel_tools
./external/bazel_tools:
tools
./external/bazel_tools/tools:
python
./external/bazel_tools/tools/python:
py3wrapper.sh
./integrations:
tensorflow
./integrations/tensorflow:
bindings e2e
./integrations/tensorflow/bindings:
python
./integrations/tensorflow/bindings/python:
pyiree
./integrations/tensorflow/bindings/python/pyiree:
tf
./integrations/tensorflow/bindings/python/pyiree/tf:
compiler support
./integrations/tensorflow/bindings/python/pyiree/tf/compiler:
binding.so __init__.py __pycache__
./integrations/tensorflow/bindings/python/pyiree/tf/compiler/__pycache__:
__init__.cpython-37.pyc
./integrations/tensorflow/bindings/python/pyiree/tf/support:
__init__.py __pycache__ tf_test_driver.py tf_test_utils.py
./integrations/tensorflow/bindings/python/pyiree/tf/support/__pycache__:
__init__.cpython-37.pyc tf_test_utils.cpython-37.pyc
./integrations/tensorflow/e2e:
math_test_manual math_test.py
Note that only the leaf directories corresponding to actual python packages have init.py files in them, which matches exactly what is in the source. When this goes wrong, you will see ever directory up the tree have them.
A reasonable workaround for when this breaks is to pass the flag --incompatible_default_to_explicit_init_py to bazel build/run. This may have other implications for other python dependent projects, though.
Activity
Add missing python dep on pathsetup.
Add missing python dep on pathsetup.