https://pantsbuild.org/ logo
#development
Title
# development
f

fresh-cat-90827

02/13/2022, 4:30 PM
hey devs. I can’t find if we already do this anywhere else in Pants. I have a list of files from
hydrated_sources.snapshot.files
. Now I’d like to copy them (while preserving the inner directory hierarchy) into a new, temporary directory that needs to exist on disk. I’ll need to pass that directory path to a binary tool. Can I access such a location in some temporary build directory somewhere?
f

fast-nail-55400

02/13/2022, 4:43 PM
The
Digest
for those source files would be passed as the
input_digest
of the
Process
used to invoke the the binary tool.
that is, use
hydrated_sources.snapshot.digest
as part of forming the input digest to the process invocation
the files will be copied into the execution sandbox during the invoation
c

curved-television-6568

02/13/2022, 5:27 PM
Also used in the docker backend for the docker build context..
For example ;)
f

fresh-cat-90827

02/13/2022, 10:24 PM
oh thanks @fast-nail-55400! Sorry, I wasn’t clear. I already use the
.digest
and it works great. I was thinking about the use case where I have files
foo/dir/bar.txt
and
baz/dir/qwe.txt
(as part of the digest). Now I wanted to merge them onto
result/dir
directory containing both
bar.txt
and
qwe.txt
so that I could pass
result
directory name to the
Process
. After experimenting, I feel it may be unnecessary, but since I’ve asked, it would be handy to know whether there is an easy/sensible way to achieve that.
f

fast-nail-55400

02/14/2022, 12:29 AM
You can use
AddPrefix
and other digest manipulation types to modify the digest.
👍 1
h

hundreds-father-404

02/14/2022, 3:34 PM
Yeah,
Digest
is the "handle" around those files. See https://www.pantsbuild.org/docs/rules-api-file-system for how you can do things like rename files