:question:*pants rebuild everything every time*:qu...
# general
c
*pants rebuild everything every time*Hi community, I understand pants supports caching and should not rebuild things if unchanged. However, for my pex_binary, even if I just changed one file (for example, the main.py file),
pants run my_pex_binary_target
will rebuild from scratch. Could someone suggest how to troubleshoot?
h
It is actually using caches for many intermediate steps, but the final step of rebuilding the packaged .pex file can be time-consuming, as it has to recreate a potentially large zip file even if just one file inside it changed.
pants run my_pex_binary_target
is shorthand for "build a .pex, then run it`
But
pants run path/to/main.py
skips the whole pex building part
so for fast-iteration runs, that's probably what you want
c
That make sense. Thank you @happy-kitchen-89482
Can I assume I need to create a separate target for main.py? should it be a python_source()?
h
You don't need to if it's already covered by a
python_sources()
, (which generates python_source targets under the covers)
👍 1
c
@happy-kitchen-89482 may I ask a follow up question: • let’s say I have a Django project, at the top level, there are three folders
a
b
c
. The three folders are for different apps of the same Django project. • at the top level, there are also utility scripts like
manage.py
• for the top level BUILD file, when I define a
python_sources
, for the sources filed of this target: ◦ is it better to be
**/*.py
which includes all the python source files under folders
a
b
c
? ◦ or would it be better to just leave it as default, and define
python_sources
in each of the
a
b
c
folders respectively?
h
It doesn't matter all that much, but maybe the latter is easier to reason about
It depends on whether you want different target field values in each app, which seems unlikely
And you can use
overrides=
to override field values for specific files anyway
c
It depends on whether you want different target field values in each app, which seems unlikely
Yep, I don’t need to. So it seems make more sense to have a single python_sources target for the entire project? Thanks
h
You can also just let
pants tailor
do its thing
Which is one per folder
👍 1