Given this BUILD file: ```file( name="dockerfile...
# general
t
Given this BUILD file:
Copy code
file(
  name="dockerfile",
  source="Dockerfile",
  dependencies=["src:pex1"],
)

archive(
  name="archive",
  files=[":dockerfile"],
  packages=["src:pex2"],
  format="zip",
)
pants package path/to:archive
yields an archive that does not contain
src:pex1
. Is this by design? Would I have to list every dependency under
files
or
packages
for it to be included in the archive? If so, is the
dependencies
list on
file
targets used for anything?
In other words, should the
archive
target pick up transitive dependencies?
r
What are you trying to do?
s
I think you might want to try referencing
src:pex1
in the
packages
for the archive instead of as a dependency of
file
. this is kind of a gut feeling to me seeing as it feels kind of weird having a
file
depend on a pex and I can see Pants not realizing it should pull it into the
archive
if it's just a dependency of the
file
target. if that works, hopefully someone else can chime in as to why it does lol. I guess my followup question would be what are benefiting from by adding
src:pex
to the dependencies for your file?
1
t
That is what I was wondering lol. I wasn't sure if there was a reason to add dependencies to a file since they are not loaded into archives. I was confused because I had assumed
file
dependencies
would be pulled into the archive the way they
dependencies
are added to
pex_binary
targets. Your comment makes sense and I ended up going with listing everything in the
packages
field. Semantically, it makes sense to me that `archive`s only worry about their own direct dependencies via
files
and
packages
. TBH it felt weird having the dependency on the file but it sort of made sense to me that the Dockerfile depends on the pex so I just added the pex as a dependency on the file. I am not using
docker_img
targets, I am just packaging the dockerfiles/docker-compose files along with dependencies to be built later.
s
yeah I definitely understand that line of thought, it's all can be quite confusing
h
sources of transitive deps should be pulled in, I think, but it sounds like what you're asking for is to build a .pex and then embed it? That's what `packages=`is for, yep
👍 1