https://pantsbuild.org/ logo
h

hundreds-breakfast-49010

02/04/2020, 9:29 PM
do we currently expect
./pants repl <python_target>
to populate the repl's namespace with symbols define in the specified target?
a

aloof-angle-91616

02/04/2020, 9:30 PM
no, we expect to
import
them
👍 1
currently
h

hundreds-breakfast-49010

02/04/2020, 9:30 PM
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

aloof-angle-91616

02/04/2020, 9:37 PM
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

hundreds-breakfast-49010

02/04/2020, 9:49 PM
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

aloof-angle-91616

02/04/2020, 9:50 PM
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

hundreds-breakfast-49010

02/04/2020, 9:51 PM
it looks like that's what it's doing
it's using the v1 pex library stuff, which I know less about
a

aloof-angle-91616

02/04/2020, 9:52 PM
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

hundreds-breakfast-49010

02/04/2020, 9:53 PM
I'm just trying to make sure I understand what's currently happening
a

aloof-angle-91616

02/04/2020, 9:53 PM
yes yes
h

hundreds-breakfast-49010

02/04/2020, 9:53 PM
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

aloof-angle-91616

02/04/2020, 9:54 PM
i think it's done in a chroot
h

hundreds-breakfast-49010

02/04/2020, 9:54 PM
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

aloof-angle-91616

02/04/2020, 9:55 PM
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

hundreds-breakfast-49010

02/04/2020, 9:56 PM
ah okay so that's what's limiting the number of source files that gets put into the pex
a

aloof-angle-91616

02/04/2020, 9:56 PM
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

hundreds-breakfast-49010

02/04/2020, 9:57 PM
I think I misunderstood another line of code
a

aloof-angle-91616

02/04/2020, 9:58 PM
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

witty-crayon-22786

02/04/2020, 10:27 PM
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

hundreds-father-404

02/04/2020, 10:49 PM
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

happy-kitchen-89482

02/05/2020, 12:47 AM
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
2 Views