https://pantsbuild.org/ logo
#general
Title
# general
h

high-yak-85899

04/25/2023, 6:04 AM
A little weird request here, but is it possible to defer a dependency that a pex needs and instead get it from the system install?
e.g. I
pip install foo
at the system layer already so
my_app.pex
doesn't also need to include
foo
when building. But it needs to find the system's
foo
when running.
Hmm maybe
PEX_INHERIT_PATH
is what I want
e

enough-analyst-54434

04/25/2023, 6:08 AM
That's 1/2 the solution, but the PEX will still suffer the bloat of a copy of the dep. Solving that is tracked here: https://github.com/pantsbuild/pex/issues/2097
h

high-yak-85899

04/25/2023, 6:09 AM
I already have it manually excluded in the build file, so I think I'm covered there.
e

enough-analyst-54434

04/25/2023, 6:09 AM
Nope
Pex does not do partial resolves. It will fill in any holes to form a transitive closure over the root requirements.
h

high-yak-85899

04/25/2023, 6:10 AM
Interesting. I definitely get different results when I add
"!!//:reqs#apache-flink"
to the
pex_binary
target. I see it not showing up in the built package
e

enough-analyst-54434

04/25/2023, 6:11 AM
So, a Pants level exclude only works if the excluded thing is not a transitive dep.
It won't work in the general case as such; so you're getting lucky right now.
Since you're excluding at the pants level it probably makes sense to seal inherit path into the PEX: https://www.pantsbuild.org/docs/reference-pex_binary#codeinherit_pathcode
I.E. That seals knowledge the PEX is broken as it stands into the PEX itself instead of needing to know that more explicitly and then use an env var in the deployment environment.
YMMV
b

bitter-ability-32190

04/25/2023, 11:58 AM
This is something we want to support in pants better. If you don't find an existing issue please file one
3 Views