-
Notifications
You must be signed in to change notification settings - Fork 179
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
add imports to fix bazel --noexperimental_python_import_all_repositories flag #630
Conversation
It's going to be a week or two before I can look at any rules_pkg things. |
Just FYI: From what I have heard, it is very likely that this flag will never be flipped. It also breaks with Bzlmod, since repository names are no longer stable identifiers in that world. |
Wdym the flag will never be flipped? Also, from the rules_python discussion
the solution in this PR doesn't use the repo name and instead uses a relative import. so from what I understand this does not depend on the repository name. Rather it just ensures that the root path of whatever py_library being used is correctly added to the path, even if bzlmod or other tooling puts it into a different directory. |
Sorry, I should have explained my point better. Essentially all information I wanted to add is that with Bzlmod, which is planned to become a full replacement for As a result, it may no longer be possible for a Python package to import one from a different repo using an import qualified with the repository name. Since setting the flag to false means that that's the only way to import across repos, the flag may no longer be usable by then. (I'm not much of a Python user myself, I just got in touch with this flag while working on improving the runfiles situation for Bzlmod. It's entirely possible I'm missing the point of this PR) |
I want to see a resolution in bazelbuild/bazel#2636 before trying to work around this. This is something that should be fixed in rules_python and not in every use case. |
I don't think this changes any existing behavior so it feels pretty safe imo rules_docker recently merged the same fix bazelbuild/rules_docker#2171 |
additionally this flag enforces #412 |
Any updates on this PR ?
In our use case we don't need to import across repos. In our monorepo, for certain This PR simply makes I would love a larger change in bazel and |
But won't solutions like this bloat your PYTHONPATH from the |
Also worth keeping in mind that |
ISTM that this PR would work in either mode. I just wonder if it actually helps. |
@amir-f is exactly right – this is necessary for |
Yes, please do, I didn't intend to say anything against merging this. I just wanted to clarify that this may not be a long term solution for the underlying problem. |
Can you merge in from head and push this again. The tests are failing as if we were picking up the WORKSPACE file without the update to a newwe bazelbuild/pllatforms. |
will do! |
In our case, the root of monorepo is added to the I understand this is just a work-around. |
OK updated with latest main. Looks like tests are passing now. |
Sorry for the slow merge. I was OOO on vacation the last 2 weeks. |
see bazelbuild/rules_python#792