E.g.: https://github.com/stevendee-recon/py-repro
That code runs fine (erroring on the invalid Company construction) if run via:
python3 -m venv venv
./venv/bin/pip3 install edgartools
./venv/bin/python app
But fails with an ImportError if run via either:
or
bazel run //app:app_bin.venv
source .app+app_bin.venv/bin/activate
python app
edgartools contains both edgar/entity/data.py and edgar/entity/data/. Apparently @rules_python populates a __init__.py under edgar/entity/data, which breaks anything that transitively imports anything out of edgar.entity.data.
My coding assistant tells me that setting enable_implicit_namespace_pkgs = True on the pip.parse in MODULE.bazel works around the issue. I’m not sure if that’s a straightforward fix or if it will break other things.
E.g.: https://github.com/stevendee-recon/py-repro
That code runs fine (erroring on the invalid
Companyconstruction) if run via:But fails with an
ImportErrorif run via either:or
bazel run //app:app_bin.venv source .app+app_bin.venv/bin/activate python appedgartoolscontains bothedgar/entity/data.pyandedgar/entity/data/. Apparently@rules_pythonpopulates a__init__.pyunderedgar/entity/data, which breaks anything that transitively imports anything out ofedgar.entity.data.My coding assistant tells me that setting
enable_implicit_namespace_pkgs = Trueon thepip.parseinMODULE.bazelworks around the issue. I’m not sure if that’s a straightforward fix or if it will break other things.