-
-
Notifications
You must be signed in to change notification settings - Fork 588
feat: env-var for additional interpreter args in bootstrap stage 1 #2654
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
feat: env-var for additional interpreter args in bootstrap stage 1 #2654
Conversation
Just thinking out loud about alternatives here. Recently we have merge #2507, which is a single target where the user get the interpreter for a particular target by:
I think it may be still missing the dependencies propagated into the interpreter environment but that was something that still needs to be done and probably is not a super heavy lift. @philsc am I right here? Env vars that in the long term may become a little bit hard to maintain and usually are a leaky abstraction. Using the interpreter target from above would allow one to just pass the args as is to the bazel run command. It does look awfully similar to what you want to build. In the command:
Is this really mandatory? What is the |
Hi @aignas;
Unless I am misunderstanding, I am unsure that this would help because the build product is still a
It acts as an argument to the |
I was thinking that the
What does the |
I'm ok with an env var for this. Just unset it after bootstrapping so it doesn't get inherited by subprocesses. A few questions/comments: Specifying a path to the new entry point: IMHO, we should allow both an arbitrary path and a runfiles-root relative path. My rationale is an arbitrary local path is handy if I just want to use a debugger I've installed locally. This will be inherently prone to problems, but that's on the user; this is just for debugging, after all. When to invoke the debugger: possible alternative? instead of |
When I mean plugin, I am referring to this. The IDE requires an SDK Python interpreter to function. This is not necessarily the exact same one present in the sandbox; it would be an external The |
I've always felt that the IDE plugin should probably integrate with debuggers differently. It does seem fragile to require or expect a "system" python to be able to run or debug a "bazel-managed py_binary". I understand why they did it this way, but I don't think anyone ever spoke to anyone from rules_python about how best to integrate :) so it's more an accident that it works at all, than by design. |
Good call; I have just added that
If I understand correctly, I am seeing this alternative has an inverse problem in that the runtime Bazel execution environment would then be "polluted" by debug dependencies and from the perspective of the IDE, the Bazel target would need to be explicitly setup to have those dependencies to be able to be debugged rather than "you can debug any By observation only, it seems like the I should point out though that no work has been done on making this function with any IDE yet; this is anticipatory.
This seems to be the case today, but as I understand it, if the IDE ends up running |
Indeed. But that seems like coupling to implementation details. It might be better for rules_python targets to expose configuration or similar that IDE can than rely on as an agreed interface, rather than IDE sniffing around inside the implementation. If the IDE are coupling to
|
Yes, true; prior to the Moving the logic for initializing the debugger into the bootloader gets a bit messy though as there's the two main debugger integrations (that I am aware of) which would be initialized in different ways, each may have their own parameters, each may be at different version, each may be version-coupled to an IDE version (eg here) and its probably not great to have their libraries being part of the Bazel build product either. In balance, I still think this env-var style approach is the better one, but perhaps the semantics about how it should work in relation to the interpreter and the target Python executable script would be good to define in documentation as well. WDYT? |
d1ef105
to
7765c36
Compare
There is no means to be able to provide additional interpreter arguments at launch time. This will make it difficult to run a `rules_python` build product from an IDE. This commit introduces a new env-var `RULES_PYTHON_ADDITIONAL_INTERPRETER_ARGS` which can be provided to the bootstrap stage 1 bash script that will invoke the Python interpreter with additional arguments. Later integration of this feature into any supporting IDE should be easier.
7765c36
to
d7ecc3b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
There is no means to be able to provide additional interpreter arguments to the
bash
-based stage 1 bootstrap system at launch time.The Intelli-J / Bazel plugin typically launches a
py_*
rule build product with something like this (abridged) using a Python interpreter from the local environment;When the
bash
-based bootstrap process is used, this mechanism not longer works. This PR will mean that a potential future Intelli-j / Bazel plugin version may be able to launch the build product differently and inject additional interpreter arguments so that the debug system can be stood up in this sort of a way;The work to support this in the Intelli-J / Bazel plugin has not been done; it would have to be undertaken some time after this change were available.