Why does the bash example (<https://github.com/pan...
# plugins
j
Why does the bash example (https://github.com/pantsbuild/example-plugin/tree/main/pants-plugins/examples/bash) uses
Process
and not
InteractiveProcess
?
h
Which part of the example? Generally, the default is to use Process because it allows for caching and concurrency. InteractiveProcess is intended for when it needs to run in the foreground so that the user can write to stdin, such as using a debugger
j
Isn't a REPL always interactive? I think I need to re-read the docs. I thought
Process
would be used to run the bash executable. But in
pants-plugins/examples/bash/bash_setup.py
I see that is not the case. Instead the
BinaryPaths
,
BinaryPathRequest
and
BashProgram
are all that is required to execute the bash repl. Does
exe: str
tell the Rust engine to "execute the binary passed to this class? In this case
bash_program_paths.first_path.path
.
h
Isn’t a REPL always interactive?
Indeed. But Jupyter is interesting because you’re not necessarily typing into the console like a normal REPL. I think you would still use
InteractiveProcess
, though, so that you have in the foreground its message about starting up and where to open the page. — Ah, I can see how that’s confusing.
bash_setup.py
only exists for utils used by the other rules. Under-the-hood, the rule for
BinaryPathRequest -> BinaryPaths
is running a
Process
to discover where on your machine the program is installed. This path is getting stored as
BashProgram.exe
, which is solely a string representing the absolute path to, say,
/bin/bash
. Then, you can use that in your other processes to set argv to be
[/bin/bash, my_script.sh]
, for example. Rather than hardcoding
/bin/bash
,
BinaryPaths
is finding `bash`’s absolute path for you. — In
repl.py
, you’re not seeing
InteractiveProcess
or
Process
anywhere because that gets handled by
core/goals/repl.py
. All your plugin does is give information needed by
core/goals/repl.py
to set up that
InteractiveProcess
. If you were to do your own new
jupyter
goal—rather than hooking into `repl`—then you would end up using
InteractiveProcess
.
😍 1