Is it expected that every time I change the file o...
# general
Is it expected that every time I change the file of the entry_point of a pex_binary that it will rebuild every requirement each time? I was hoping for something like Docker where the build process is cached at each stage and altering code (which does not require different packages) is very quick if kept as last layer. But when I use
pants run :cli
it will rebuild all the package each time I just change the source code.
โœ… 1
Hi, that's because
pants run
on a pex_binary actually builds the pex and then runs it. Instead you can
pants run
on a source file (typically the main of the binary) and it will run on the loose sources, without rebuilding an intermediate pex.
So will be fast
In the first case it's not necessarily rebuilding every requirement (that should be cached - if it isn't that is a separate issue), but it is repackaging the .pex file, and that takes time
In the second case you bypass that
Aha! Thank you!
But this won't know about the dependencies that the file will require. So probably export the virtualenv and run the script until requirements change?
It will. Dependency inference is working presumably, and if not, in most cases it's appropriate to move any explicit dependencies you must list to a
target covering that file.
I see. Thank you @happy-kitchen-89482 and @enough-analyst-54434. Pants is an absolutely amazing tool!
๐Ÿ™ 2
Yep, the deps properly belong to the source, not the binary, the binary is just metadata saying "build a pex from this"
๐Ÿ‘ 2
This is great and will change how I've been putting together BUILD files.
and to be clear about what not using a
avoids: all of the actual requirements going into the pex binary are cached as built wheels, so you arenโ€™t actually rebuilding wheels each time: just copying them into an output binary.
That makes more sense taking into consideration the timings. The stdout does say building requirements so that is a little confusing.
Quick question @happy-kitchen-89482 do you know of a good way to pants run on a source file that that is meant to be run through another application, for example, streamlit run or a uvicorn app?
๐Ÿ‘€ 1