flat-zoo-31952
11/27/2020, 8:12 PMhundreds-father-404
11/28/2020, 1:16 AM./pants list ::
https://github.com/pantsbuild/pants/blob/master/src/python/pants/backend/python/mixed_interpreter_constraints/py_constraints.py
It’s confusing that there are two types of targets at play, and you decide which you care about. The naming in that code is stale..
”explicit targets”, aka BUILD targets, are what you specify exactly in your BUILD file, eg the entire sources
field is used. This is all there was in Pants 1.x
“Expanded targets”, aka “file targets”, aka “generated subtargets”, are based on the original BUILD target. They have all the same metadata, except only one file in the sources
field. This is what we mean by “files are the atomic unit”; you can use a more precise subset of the original BUILD file targetflat-zoo-31952
11/30/2020, 6:09 PMhundreds-father-404
11/30/2020, 6:16 PMsources
, then we always use the original BUILD target, as it’s impossible to make it more precise
It might also be helpful to filter by target type. The simplest way is to do isinstance(tgt, PythonRequirementLibrary)
. I don’t think the more portable way of using if tgt.has_field(PythonRequirementsField)
is relevant, unless you plan to to subclass the target type