I need some assistance getting my Jupyter plugin t...
# plugins
j
I need some assistance getting my Jupyter plugin to load the targets onto the
sys.path
. @hundreds-father-404 has pointed me to
PEX_EXTRA_SYS_PATH
but the way it is implemented in
pants.backend.python.goals.repl
I am not sure how it gets to
pants.core.goals.repl
. The relevant goal (
create_ipython_repl_request
) is only found in the latter and not the former which my plugin is templated from.
The partially working code can be found at https://gist.github.com/rcuza/bbcf8f5a13964db7760ff376649c1a44
My question is what is a good way to add
PEX_EXTRA_SYS_PATH
so my targets get added to the
sys.path
as happens when one runs
pants repl :target
?
Ahhh. Is
create_ipython_repl_request
a goal that the pants engine does something with? So if I start with the following input -> output rules [
PythonRepl
,
PexEnvironment
->
ReplRequest
] then the engine will magically implement the logic within
create_ipython_repl_request
?
If that's true, then my question becomes, should I implement the changing of the
sys.path
within my current goal or should I make a new goal?
Or better yet, is there a clean way for me to use the existing
create_python_repl_request
so I can simplify my plugin?
h
Where that setting of
PEX_EXTRA_SYS_PATH
is more a question of how things are factored, and less how the logic works. It’s similar to normal programming, that you could inline everything into one huge
main()
block; or you can factor out helper functions to make things more readable and reduce duplication. The important part is setting
PEX_EXTRA_SYS_PATH
in the
env
var for your
InteractiveProcess
object, wherever that is being created, regardless of if it’s in a
@goal_rule
or some helper rule.