aloof-angle-91616
05/15/2020, 9:09 AMaloof-angle-91616
05/15/2020, 10:11 AMaloof-angle-91616
05/15/2020, 11:59 AMwitty-crayon-22786
05/16/2020, 5:25 AMhundreds-father-404
05/18/2020, 3:46 AM.pants
folder. Possibly, keep dist/
. We rejected it then because of the clean-all
goal’s behavior, but we could change how that goal behaves. https://github.com/pantsbuild/pants/issues/3511witty-crayon-22786
05/18/2020, 5:02 PMclean-all
doesn’t affect v2 at all =x … some semantics to figure out there.witty-crayon-22786
05/18/2020, 6:45 PMwitty-crayon-22786
05/18/2020, 6:48 PMhundreds-father-404
05/19/2020, 6:07 AMBuildFileAddress
, such as getting it to no longer subclass Address
but instead compose it with a dataclass (long standing TODO). I think it’s too entrenched to get right, though. It’d be easiest to start from scratch.
The only issue is the name. I like BuildFileAddress
, but it’s claimed. Thoughts on BuildAddress
? Any suggestions on other names?hundreds-father-404
05/19/2020, 6:09 AMAddressWithBuild
? AddressWithBuildPath
? The TODO from Benjy suggests ~ this design, which I think makes sense:
@dataclass(frozen=True)
class AddressWithBuild
address: Address
build_path: str
hundreds-breakfast-49010
05/20/2020, 10:50 PMwitty-crayon-22786
05/20/2020, 10:51 PMhundreds-father-404
05/20/2020, 10:54 PMhundreds-breakfast-49010
05/20/2020, 10:57 PMwitty-crayon-22786
05/20/2020, 10:58 PMwitty-crayon-22786
05/20/2020, 10:59 PMhundreds-father-404
05/20/2020, 11:28 PMhundreds-father-404
05/20/2020, 11:28 PMwitty-crayon-22786
05/20/2020, 11:29 PMhundreds-father-404
05/20/2020, 11:29 PMhundreds-father-404
05/20/2020, 11:30 PMhundreds-father-404
05/20/2020, 11:30 PMwitty-crayon-22786
05/20/2020, 11:30 PMwitty-crayon-22786
05/20/2020, 11:31 PMhundreds-father-404
05/20/2020, 11:46 PMdependencies
in your BUILD file and Pants will do the right thing based on import statements)
--
We need to convert Dependencies
from a PrimitiveField
to AsyncField
so that the engine can do its magic. Call sites would look like:
await Get[Addresses](DependenciesRequest(tgt.get(Dependencies))
This means we have one rule to go from DependenciesRequest -> Addresses
, just like we have one rule to go from HydrateSourcesRequest -> HydratedSources
.
Fine and good.
--
The challenge is with codegen dependency injection. Specifically, that that injection will need to access subsystem options, e.g. --protoc-runtime-targets
. It will need a SubsystemRule
.
But, we can’t have our generic DependenciesRequest -> Addresses
rule request that subsystem because it has no idea it’s needed. Instead, in the rule, we need a way to say something like “If there are any injected dependencies for this Dependencies
field, run the rule to inject those.”
This is unions, right? Something like:
injected_deps = await Get[InjectedDependencies](InjectDependenciesRequest, dependencies_field)
And then the Protoc backend would define a rule that goes from (ProtocDependencies, Protoc) -> InjectedDependencies
, where ProtocDependencies
belongs to the union?witty-crayon-22786
05/20/2020, 11:50 PMwitty-crayon-22786
05/20/2020, 11:53 PMwitty-crayon-22786
05/20/2020, 11:55 PMProtocSources
-> PythonSources
… the analogue here would be to use typed dependencies in all cases too? PythonDependencies
…?witty-crayon-22786
05/20/2020, 11:57 PMDependenciesRequest
would need output type information, basically.hundreds-father-404
05/21/2020, 12:00 AMsomething about that feels strange, because for sources, the conversion is ProtocSources -> PythonSourcesThis is not true. The conversion is
HydrateSourcesRequest(ProtobufSources) -> HydratedSources
. We only use PythonSources
as a way to express intent that “I want this to be something like PythonSources”.
I don’t think we need that notion here. You will always get all dependencies - the call site can filter out irrelevant ones, like how we do currently in importable_python_sources.py
.
Part of the reason we do not need to specify the “output type” is that there’s no ambiguity problem, here. With codegen of sources, you can go from ProtobufSources to multiple different languages, but you only want one distinct language.
With dependencies, it’s fine for us to add all the runtime dependencies; it’s acceptable afaict if we always injected a JarLibrary
, PythonRequirementLibrary
, etc, when calling await Get[Addresses](DependenciesRequest(protobuf_library[Dependencies])
. The call site can ignore the JarLibrary
if it wants to