Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix python import issue #13

Merged
merged 3 commits into from
Oct 6, 2022
Merged

Conversation

LiyouZhou
Copy link
Contributor

Traditionally bazel created init files in the root of the build folder of python packages, this causes confusion during python import when the build folder name is the same as the package name. See this discussion. So you end up with:

- my_package
  - __init__.py <==== created by bazel
  - my_package <==== copy of the source code
     - __init__.py <==== from the actual source code

legacy_create_init=False will prevent this __init__.py from being created.

@mvukov
Copy link
Owner

mvukov commented Oct 6, 2022

Thanks for the contribution. Which Bazel version are you using btw?

I use 5.2 on daily basis and until yesterday I haven't had any problems using --incompatible_default_to_explicit_init_py option (which is also in .bazelrc of this repo and I hope you use it as well). And then I found a Bazel bug, see bazelbuild/bazel#16388. Looks like you have the same issue here. Extra flags won't harm. LGTM!

@mvukov mvukov merged commit fc0924d into mvukov:main Oct 6, 2022
@LiyouZhou LiyouZhou deleted the liyou/fix_python_import_issue branch October 7, 2022 13:10
@LiyouZhou
Copy link
Contributor Author

Thx, currently bazel 5.3.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants