Hi community! When working with pants to build st...
# general
a
Hi community! When working with pants to build standalone pex files. Is there an opinionated way to change the dist path in the relevant BUILD filed? It seems the output path option only changes the name of the object being generated not the dist path itself. My use case is keeping modules in version control via lfs, where each pex file represents a snapshot of a given release. To this end, does pants keep track of the build/package state of pex files? i.e. when triggering
./pants package example
is this operation repeated regardless of changes?
e
It seems the output path option only changes the name of the object being generated not the dist path itself.
I assume you're using https://www.pantsbuild.org/docs/reference-pex_binary#codeoutput_pathcode - which is the right idea. If you configure:
Copy code
[GLOBAL]
pants_distdir = "%(buildroot)s"
Then you should find:
Copy code
pex_binary(
    ...
    output_path="foo/bar/baz"
)
Nets you a PEX file
baz
at
foo/bar/baz
in your repo after running
./pamts package ...
on the `pex_binary`target.
🙌 1
i.e. when triggering
./pants package example
is this operation repeated regardless of changes?
Yes. In fact all Pants operations that produce visible output files act this way. They basically can't assume the file already on the filesystem is up to date. IOW Pants does not 1st look at the output path, see if there is a file, checksum it and proceed from there. It does do something like that for all internal - invisible to you in normal circumstances - sandboxed operations, just not the final operations that materialize output to disk in your workspace.
a
Makes sense. Thanks for clarifying John. I guess in the end git should pick up changes and regardless of the rebuild.
h
Note that you can use
./pants --changed-since=main --changed-dependents=transitive
to rebuild all packages that are affected by changes in git.
✅ 1
Otherwise,
/pants package example
will repeat just the final step of writing to your workspace, but the work leading up to that will be retrieved from cache, if possible.