Bit of a strange question here, but it might be th...
# development
w
Bit of a strange question here, but it might be the 1am causing it. For python, if I have a
dep
which is a
pex_binary
- that should necessarily already have
interpreter_constraints
resolved, correct? If so, is there any way to just "get" those resolved constraints? Right now, I'm doing this, which seems silly for a target that has already resolved its constraints.
Copy code
interpreter_constraints = InterpreterConstraints.create_from_targets(
        direct_deps, python_setup
    ) or InterpreterConstraints(python_setup.interpreter_constraints)
I thought a
FieldSetsPerTargetRequest
with a
PexBinaryFieldSet
had potential, but that's an empty collection. And
dep_target.get(InterpreterConstraintsField))
returns
None
I may be thinking about this at the wrong level, because the interpreter_constraints are resolved during packaging of the pex binary I guess, which I think happens after I get a BuiltPackage - so this may be an order of operations problem
w
you only need the `pex_binary`’s constraints: none of its deps.
this changed in the last few versions: we didn’t use to validate that a target had ICs which were compatible with its deps, but now we do.
you only need the `pex_binary`’s constraints: none of its deps.
with defaulting to the global default as you did there
w
I'm using the
pex_binary
as a dep to my target - so grabbing those constraints is what I'd like to do
w
sure
w
So, what I did is reasonable, since the
pex_binary
didn't have any explicit
interpreter_constraints
specified?
w
no:
pex_binary
does have an
interpreter_constraints
field
so you want just:
Copy code
interpreter_constraints = InterpreterConstraints.create_from_targets(
        pex_binary, python_setup
    ) or InterpreterConstraints(python_setup.interpreter_constraints)
maybe i’m misunderstanding you though.
w
I think we're on the same page. In my case, "direct_deps" is the potential for more than 1 pex (which I don't yet know is even valid). The trivial case will reduce it to just a single pex_binary
w
this was the change where we began validating that a target always has ICs which are a subset of its dependencies: https://github.com/pantsbuild/pants/pull/15373
k, yea: sounds right then.
👍 1
w
Cool, thanks!