do we currently expect `./pants repl <python_ta...
# general
h
do we currently expect
./pants repl <python_target>
to populate the repl's namespace with symbols define in the specified target?
a
no, we expect to
import
them
👍 1
currently
h
for instance if I run
./pants repl src/python/pants/engine:fs
I still need to
import fs
to have access to data structures defined there?
a
yes!
or rather
import pants.engine.fs
since we know all the namespaces the target is supposed to have, it would be very cool to have that auto-populated
h
cool
I'm trying to figure out how v1 repl works so I can implement it in v2
not sure how hard it would be to do the auto-population thing
a
we already try to inject init files where they need to be which feels similar
v1 repl i thought just created a pex and ran it
h
it looks like that's what it's doing
it's using the v1 pex library stuff, which I know less about
a
a huge amount of that complexity is incidental
👍 1
i would like to potentially avoid copying that if possible unless you're finding a reason to
h
I'm just trying to make sure I understand what's currently happening
a
yes yes
h
it looks like every single file in the workdir is being added to the pex in v1? if I'm understanding this correctly
I'm sure we don't want that
a
i think it's done in a chroot
h
in
python_repl.py
the
setup_repl_session
method makes a defualt PexInfo and then calls
create_pex
with it
ah ok
do you know where that chroot is configured?
a
no i am looking
lmao
ok
so
(1) ResolveRequirements will create a requirements pex
(2) GatherSources will create a sources pex
(3)
self.create_pex()
in
PythonExecutionTaskBase
will create a pex file which merges those two
h
ah okay so that's what's limiting the number of source files that gets put into the pex
a
yes
or well
not sure where you're getting that it's adding all the files from the workdir
GatherSources should be doing it file-by-file i think? let me check
h
I think I misunderstood another line of code
a
there are a lot of them
i think GatherSources only adds files from source targets, it uses the
.add_sources_from()
method from
PexBuildUtil
w
python has import sideeffects
👍 2
and on most platforms, imports have some costs (it's when things are actually loaded)
so i don't know if changing the semantics of the repl is desirable (not by default, prolly)
👍 1
h
Agreed that autoloading is surprising. This opens up questions like how to handle two modules using the same import names, which will cause the REPL to fail Instead, I think we act like IPython behaves on the CLI, where you must still import things like
import re
and
import pathlib
h
It would be nice to do autoloading in the future (e.g., the django
shell_plus
extension does this to import all your models) but this is not required for feature parity with v1
so let's not worry about it right now