future-oxygen-10553
03/22/2023, 8:06 PMpex_binary
target with only the dependencies (including first-party dependencies) of a particular target (actually, a python_sources
target generator). Is there a way I can tell pants to do this with the dependencies
field of the pex_binary
target? The use case is that I have some workflow code which is uploaded to my Docker image by a separate tool (Flyte), so I only want my pex that I’m unpacking into a venv to include 3rd party and 1st party dependency code. Thanks!witty-crayon-22786
03/22/2023, 8:19 PMpython_sources
target in the dependencies
list of the pex_binary
?future-oxygen-10553
03/22/2023, 8:23 PMpython_source
targets in the pex. So if my directory structure is:
.
├── src
│ ├── cmi_db
│ └── cmi_orchestration
└── pants.toml
My pex_binary
should have code from 3rd party and cmi_db
in it, but not cmi_orchestration
, where code in cmi_orchestration
imports code from cmi_db
(and not vice-versa), so pants can infer the first-party dependencygorgeous-winter-99296
03/22/2023, 8:26 PMfuture-oxygen-10553
03/22/2023, 8:27 PMsrc/cmi_orchestration
as the pex_binary
dependency
, then that code is also included in the srcs
. What I want is all the dependencies of src/cmi_orchestration
, without having to list them manuallywitty-crayon-22786
03/22/2023, 8:28 PMfuture-oxygen-10553
03/22/2023, 8:29 PMwitty-crayon-22786
03/22/2023, 8:31 PMwitty-crayon-22786
03/22/2023, 8:31 PMfuture-oxygen-10553
03/22/2023, 8:34 PMsrc/cmi_db
is the first party code upon which the src/cmi_orchestration
depends, so pants can infer the dependency, and src/cmi_orchestration
is the code uploaded by Flyte into the container. I could list src/cmi_db
in the dependencies
of the pex_binary
but of course there are many more first-party packages than src/cmi_db
that are dependencies of src/cmi_orchestration
🙂 So listing them all manually is feasible, but likely to go out-of-date as the code in src/cmi_orchestration
changes, and since pants already knows about the dependencies, I was hoping there’d be a way to specify thisgorgeous-winter-99296
03/22/2023, 8:49 PMgorgeous-winter-99296
03/22/2023, 8:50 PMcmd/app1.py
I have
import plugin1 # noqa: for dep inference
import plugin2 # noqa: ...
import app
app.run()
future-oxygen-10553
03/22/2023, 8:52 PMgorgeous-winter-99296
03/22/2023, 8:57 PMimport plugin1
f.ex... If that is just an empty __init__.py
you'll likely get less than you expect.
pants dependencies --dependencies-transitive cmd/app1.py
Will list that whole closure.