high-yak-85899
02/09/2022, 4:57 PMhigh-yak-85899
02/09/2022, 4:58 PMhigh-yak-85899
02/09/2022, 4:59 PMBUILD
files properly populated all the way down and I'd like for another target to depend on all the python_sources
listed there.high-yak-85899
02/09/2022, 5:00 PMmy/path/**/*.py
or something similar to pick up what I need)bitter-ability-32190
02/09/2022, 5:04 PMname
given to a python_sources()
target to see if that works.
Othwerise, Pants doesn't have this functionality AFAIK although future changes could allow this (can't find the google doc link...).
If you're importing using strings and importlib
, you could try out https://www.pantsbuild.org/docs/reference-python-infer#section-string-importshigh-yak-85899
02/09/2022, 5:05 PMhigh-yak-85899
02/09/2022, 5:06 PMimportlib
with strings is exactly what we're doing right now.bitter-ability-32190
02/09/2022, 5:06 PMname
route, then yeah one dependency per directory (try it out on one dir first though, I'm not sure if it'd work so don't waste time if it doesn't)bitter-ability-32190
02/09/2022, 5:07 PMfoo.bar.baz
then string-imports
should workhigh-yak-85899
02/09/2022, 5:07 PMbitter-ability-32190
02/09/2022, 5:07 PMbitter-ability-32190
02/09/2022, 5:08 PMname
is your only hope then, today.bitter-ability-32190
02/09/2022, 5:09 PMhigh-yak-85899
02/09/2022, 5:16 PMpython_infer
toobitter-ability-32190
02/09/2022, 5:19 PMpython_sources()
which globs subdirs, but can be overriden at a subdir-level BUILD
if needed. Today Pants sees both and doesn not attempt to selectbitter-ability-32190
02/09/2022, 5:20 PMpython_sources()
override
field for individual files if you need to override info. But you'll have to specify it relative to the BUILD
file dirbitter-ability-32190
02/09/2022, 5:20 PMhigh-yak-85899
02/09/2022, 5:49 PMhigh-yak-85899
02/09/2022, 5:50 PMbitter-ability-32190
02/09/2022, 5:51 PM[python-infer].string_imports
would only help if you were using static strings for the module name, in-codehigh-yak-85899
02/09/2022, 5:54 PMmy.specific.folder.*
?bitter-ability-32190
02/09/2022, 5:58 PMbitter-ability-32190
02/09/2022, 5:58 PM__import__("foo.bar")
or importlib.import_module("foo.bar")
high-yak-85899
02/09/2022, 6:00 PMhappy-kitchen-89482
02/09/2022, 6:02 PMhappy-kitchen-89482
02/09/2022, 6:02 PMhappy-kitchen-89482
02/09/2022, 6:02 PMhappy-kitchen-89482
02/09/2022, 6:03 PMhigh-yak-85899
02/09/2022, 6:06 PMscript_runner.py
in one place and then a folder of all/my/scripts
elsewhere (which has subfolders after that). The user specifies the path like all/my/scripts/folder1/this_script.py
to run and script_runner.py
would importlib
that in and execute it. So I was hoping for an extensible way to say that script_runner.py
depends on all of the python_sources
in all/my/scripts
.high-yak-85899
02/09/2022, 6:07 PMall/my/scripts
and then turn script_runner.py
into pex_runner.py
high-yak-85899
02/09/2022, 6:07 PMhappy-kitchen-89482
02/09/2022, 6:56 PMscript_runner.py
and a rule that injects all those deps onto it is probably the way to go.