-
Notifications
You must be signed in to change notification settings - Fork 556
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
rules_python 0.26 changes behavior for sequence of py_repositories call #1560
Comments
Not sure, but my guess here is this is a side effect of having repo rules and regular rules in the same bzl file. i.e. pip.bzl. This has both pip_parse (repo rule) and compile_pip_requirements (regular rule that loads py_binary). We should split pip.bzl up to better separate the repo-rules from regular-rules. Or maybe put a call to py_repositories in register_python_toolchains() ? I'm not sure that would fix it. Not sure we should do that, either. The core issue, though is before using anything from rules_python, I think this also is because of an annoying behavior WORKSPACE has? I don't fully remember/understand, but I think it's something like: repos created during a macro call aren't actually created/usable until execution returns back to the WORKSPACE file. Or something like that? This would explain why changing the py_repositories() call in |
Is this something the Bazel team will consider?
Yes (assuming you meant
Agreed, though we are trying to avoid this because it needs to be proliferated to many repos. These helper macros were intended to simplify WORKSPACE boilerplate (actually, I got some pushback because folks wanted a single macro which wasn't possible). |
Is this still relevant? |
If there has been any suspected fix for this issue, happy to give it a try. We are still using rules_python-0.25.0 to avoid this problem. |
I'm getting the same error, but my
with
To fix it, I had to move the |
Closing. It appears there is a workaround and the maintainers won't be looking at this issue any time soon. Future work on the rules is focussed on |
🐞 bug report
Affected Rule
The issue is caused by the rule:It seems to be a new behavior introduced in rules_python 0.26 that forces the
py_repositories
call to take place before loading other rules_python loads:Seems to be related to #1428.
Is this a regression?
Yes, the previous version in which this bug was not present was: 0.25.0Yes, the
py_repositories()
call can take place later within a helper function of a .bzl file with other rules_python loads (see below).Description
A clear and concise description of the problem...In rules_python 0.25, using Bazel workspaces, the following works:
This same WORKSPACE sequence fails in rules_python 0.26. To avoid updating every repo WORKSPACE we have, the only workaround seems to be to move the
py_repositories
call to anywhere within theinitialize_python_toolchain
helper function. It does not seem to matter whether that call happens before or after the call topython_register_toolchains
. It just must be before theinterpreter
andpip_parse
loads (movingpy_repositories
before any other external dep helpers insideinitialize_external_deps
does not matter).🔬 Minimal Reproduction
See above.
🔥 Exception or Error
🌍 Your Environment
Operating System:
Output of
bazel version
:Rules_python version:
Anything else relevant?
I couldn't figure out if there was a single load that mattered from:
I tried selectively removing one or the other (stuff downstream should still fail due to missing references) but they still failed early at the missing
rules_python_internal
. Only when I remove both does it generate a different error (about missing pip_parse reference).The text was updated successfully, but these errors were encountered: