proud-dentist-22844
05/25/2023, 4:39 AMpython_distribution
, pex_binary
, debian_package
, and now the nfpm package types I'm working on).
In many cases, these packages depend on another package, we want to include the package/archive itself, not the sources packaged in the target or owned by the target. For python_distribution
there's quite a bit of logic to determine which distribution "owns" a given python source file. Some package targets (like debian_package
) use a SpecialCasedDependency field to exclude their deps from normal dep calculation.
So, what if we allow passing a predicate (lambda function) when requesting transitive deps that says whether or not to follow the dependencies of a given target. Maybe something like this (probably with the predicate on TransitiveTargetsRequest
instead of on the _DependencyMappingRequest
)? https://github.com/cognifloyd/pants/commit/b4044e76685041cdac322a3e96f4858b4634f045
(For what it's worth, mypy is happy with this stub commit.)
Do any other request types use a lambda like this? Is that going to mess up graph calculation some how? I tried to minimize the effect on the current predicate-less code path, but I'm not sure about the performance implications of messing with the dep graph here.
Should I keep going with this approach?proud-dentist-22844
05/25/2023, 2:32 PMhappy-kitchen-89482
05/25/2023, 3:01 PMhappy-kitchen-89482
05/25/2023, 3:04 PMhappy-kitchen-89482
05/25/2023, 3:04 PMpex_binary
? So the graph traversal itself should understand that concept?happy-kitchen-89482
05/25/2023, 3:05 PMpaths
goal or similar)happy-kitchen-89482
05/25/2023, 3:06 PMhappy-kitchen-89482
05/25/2023, 3:06 PMhappy-kitchen-89482
05/25/2023, 3:06 PMhappy-kitchen-89482
05/25/2023, 3:06 PMhappy-kitchen-89482
05/25/2023, 3:07 PMproud-dentist-22844
05/25/2023, 3:18 PMproud-dentist-22844
05/25/2023, 3:20 PMproud-dentist-22844
05/25/2023, 3:21 PMOutputPathField
? Nope. Every package type implements its own PackageFieldSet
.proud-dentist-22844
05/25/2023, 3:40 PMFieldSet
class, and then use its .is_applicable
classmethod as the predicate. Then, if that returns True, skip that target's dependencies.
Or, I could also just grab all union_membership.get(PackageFieldSet)
and do that for all of them.bitter-ability-32190
05/25/2023, 3:48 PMbitter-ability-32190
05/25/2023, 3:49 PMproud-dentist-22844
05/25/2023, 4:03 PMPackageFieldSet
into the engine internals which is a little gross. :/ Moving it is an option as well.proud-dentist-22844
05/25/2023, 4:05 PMbitter-ability-32190
05/25/2023, 4:22 PMpex_binary
) or as the packaged thing (I intend to upload this artifact
using my super special script).
Tagging allows that vital information to be known to Pants, therefore we make less assumptions (exactly 0 assumptions š)bitter-ability-32190
05/25/2023, 4:23 PMhappy-kitchen-89482
05/25/2023, 4:36 PMhappy-kitchen-89482
05/25/2023, 4:37 PMhappy-kitchen-89482
05/25/2023, 4:38 PMbitter-ability-32190
05/25/2023, 4:40 PMwitty-crayon-22786
05/25/2023, 4:42 PMbitter-ability-32190
05/25/2023, 4:42 PMproud-dentist-22844
05/25/2023, 4:43 PMproud-dentist-22844
05/25/2023, 4:44 PMwitty-crayon-22786
05/25/2023, 4:45 PMwitty-crayon-22786
05/25/2023, 4:46 PMproud-dentist-22844
05/25/2023, 4:47 PMwitty-crayon-22786
05/25/2023, 4:48 PMDependencies
field subtype or anotherwitty-crayon-22786
05/25/2023, 4:48 PMTypeOne -> TypeTwo
witty-crayon-22786
05/25/2023, 4:49 PMproud-dentist-22844
05/25/2023, 4:51 PMhappy-kitchen-89482
05/25/2023, 4:54 PMproud-dentist-22844
05/25/2023, 5:34 PMpython_distribution
traversing all the other python_distribution
targets, if a python source under dist A imports python source under dist B, and dist B explicitly depends on dist A, then dist A will package that source even if none of the entry points depend on it.
Once we stop traversing the graph through package deps, we may have to be much more explicit about what each dist includes (esp for library dists that don't have entry points).proud-dentist-22844
05/25/2023, 5:41 PMproud-dentist-22844
05/25/2023, 5:41 PMproud-dentist-22844
05/25/2023, 5:41 PMproud-dentist-22844
05/25/2023, 6:41 PMproud-dentist-22844
05/25/2023, 6:48 PMproud-dentist-22844
05/25/2023, 10:49 PMwitty-crayon-22786
06/01/2023, 7:11 PMbitter-ability-32190
06/01/2023, 7:11 PMproud-dentist-22844
06/01/2023, 11:30 PMSpecialCasedDependencies
, to figure out what use-cases it covers... š¤Æ
Handling archive
and debian_package
look fairly straight forward, and then it gets fuzzier but still doable (via tagged dependencies?) for python_test(s)
, shunit2_test(s)
, pex_binar{y,ies}
, python_{google_cloud,aws_lambda}_function
, python_aws_lambda_layer
, adhoc_tool
, shell_command
, run_shell_command
, system_binary
, and helm_deployment
. And then wrap_source_as_*
and relocated_files
need something a bit different, but probably still doable.
But then there's jvm_war
. Geez. The complexities around handling java are so painful.bitter-ability-32190
06/01/2023, 11:40 PMproud-dentist-22844
06/01/2023, 11:41 PMwitty-crayon-22786
06/02/2023, 12:36 AMSpecialCasedDependencies
is: āwe want to support multiple subclasses of Dependencies
on one Targetāwitty-crayon-22786
06/02/2023, 12:37 AM