You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some languages supported by pants (Python and JVM notably) can produce targets that are executable only if their runtime is present. This means Pants needs machinery to make the runtime available in the sandbox for any target that the user wants to run.
The current art for this, adhoc_tool, supports providing a single target as its runnable. This obviates the need for e.g. giving the entry point a name, or differentiating between whether a target is being used as something that should be run, or something that is merely being used as runtime data.
One notable flaw in this approach is that multiple runnable targets cannot be provided. This prevents simple cases of composition in shell_command; it also prevents runnable targets from describing targets that will be invoked as subprocesses when run.
#18082 described the possibility of adding a runnable_dependencies field to the shell_command target. This is possibly acceptable as an experimental feature, noting that these dependencies could only be defined on the shell_command: It would not be possible to describe child runnable dependencies on targets that are themselves pulled in as runnable. This means that if there were multiple shell_commands using the same basic runnable, each of them would need to declare the runnable's runnable dependencies.
A better approach would be to be able to add runnable dependencies to the targets themselves, which would be brought in by pants run or shell_command or adhoc_tool.
The shell_command target's tools field could also be replaced with runnable dependencies, if shell tools were made available as runnable dependencies by way of Synthetic targets.
This ticket needs further design before implementation. The author believes this looks a lot like scoped dependencies (#12794), and a genuinely good design for runnable dependencies would probably fall out from solving scoped dependencies well.
The text was updated successfully, but these errors were encountered:
#18347 includes a lot of the machinery for introducing runnable dependencies into the sandbox (yay), but does not provide a good solution for:
Flexibility of target names. If a runnable needs to call foo, the target that provides the /usr/bin/env foo must itself be named foo
Transitive dependencies. If a runnable foo needs to call bar, every place where foo is run needs to declare bar as a runnable_dependency.
I lean towards a solution where you can tag the dependencies from within the dependencies field (as I attempted in an early commit in #18347), rather than adding in new fields: if a target is runnable, then it should be able to specify its runnable dependencies. Targets shouldn't have their utility limited by not being to run subprocesses because the plugin author forgot to add a field.
…dependencies` field (#18347)
This adds a `runnable_dependencies` field to `adhoc_tool` and
`shell_command`, as well as a `fingerprint_dependencies` field to
`system_binary`.
This allows users of `adhoc_tool`/`shell_command` allows users to write
rules that consume a pinned version of `yarn`, which in turn calls a
pinned version of `node`.
This partially addresses #18320, but makes `BUILD` files extremely
repetitive at the moment, so does not constitute a full solution to the
problem. This PR is intended in the spirit of "if we can't make it easy,
at least make it possible".
---------
Co-authored-by: Andreas Stenius <git@astekk.se>
Some languages supported by pants (Python and JVM notably) can produce targets that are executable only if their runtime is present. This means Pants needs machinery to make the runtime available in the sandbox for any target that the user wants to run.
The current art for this,
adhoc_tool
, supports providing a single target as itsrunnable
. This obviates the need for e.g. giving the entry point a name, or differentiating between whether a target is being used as something that should be run, or something that is merely being used as runtime data.One notable flaw in this approach is that multiple runnable targets cannot be provided. This prevents simple cases of composition in
shell_command
; it also prevents runnable targets from describing targets that will be invoked as subprocesses when run.#18082 described the possibility of adding a
runnable_dependencies
field to theshell_command
target. This is possibly acceptable as anexperimental
feature, noting that these dependencies could only be defined on theshell_command
: It would not be possible to describe child runnable dependencies on targets that are themselves pulled in as runnable. This means that if there were multipleshell_command
s using the same basic runnable, each of them would need to declare the runnable's runnable dependencies.A better approach would be to be able to add runnable dependencies to the targets themselves, which would be brought in by
pants run
orshell_command
oradhoc_tool
.The
shell_command
target'stools
field could also be replaced with runnable dependencies, if shell tools were made available as runnable dependencies by way of Synthetic targets.This ticket needs further design before implementation. The author believes this looks a lot like scoped dependencies (#12794), and a genuinely good design for runnable dependencies would probably fall out from solving scoped dependencies well.
The text was updated successfully, but these errors were encountered: