bitter-ability-32190
06/06/2022, 3:07 PMsrc/python/pants/jvm/non_jvm_dependencies.py
is/does?ancient-vegetable-10556
06/06/2022, 3:08 PMbitter-ability-32190
06/06/2022, 3:08 PMancient-vegetable-10556
06/06/2022, 3:09 PMancient-vegetable-10556
06/06/2022, 3:10 PMbitter-ability-32190
06/06/2022, 3:10 PMbitter-ability-32190
06/06/2022, 3:12 PMNoopClasspathEntryRequest
need field sets at all if they aren't used? 🤔ancient-vegetable-10556
06/06/2022, 3:12 PMancient-vegetable-10556
06/06/2022, 3:12 PMbitter-ability-32190
06/06/2022, 3:13 PMasset
unification proposalancient-vegetable-10556
06/06/2022, 3:16 PMjvm/compile.py
— there’s a method ClasspathEntryRequestFactory.for_targets
. This is used to find an implementation that fulfils a JVM-compatible dependency. It’s necessary because there are multiple implementations for fulfilling JVM dependencies (java compiler, scala compiler, 3rd-party package resolution, etc). It figured out which implementation to use based on the fieldsets on the dependency target, and each implementation specifies which fieldsets it’s compatible withbitter-ability-32190
06/06/2022, 3:17 PMancient-vegetable-10556
06/06/2022, 3:17 PMfile
dependency, there’d be no implementation to fulfil its dependency, so the compile would fail.
We made the decision at the time that it would be better to handle a no-op compile in a generic and extensible way than to special-casesancient-vegetable-10556
06/06/2022, 3:17 PMbitter-ability-32190
06/06/2022, 3:17 PMancient-vegetable-10556
06/06/2022, 3:17 PMresources.py:assemble_resources_jar
bitter-ability-32190
06/06/2022, 3:18 PMancient-vegetable-10556
06/06/2022, 3:18 PMancient-vegetable-10556
06/06/2022, 3:18 PMClasspathEntryRequest
implementationancient-vegetable-10556
06/06/2022, 3:18 PMJvmResourcesRequest
is the special-case implementation for resource, jfyibitter-ability-32190
06/06/2022, 3:19 PMancient-vegetable-10556
06/06/2022, 3:20 PMancient-vegetable-10556
06/06/2022, 3:22 PMcompile.py:calculate_jvm_request_types
— each ClasspathEntryRequest
subclass needs some way of generating a .jar
(actually just a zip with a specific directory structure).
In JVM land, generating a .jar
is unavoidable*, so you’ll need some way to do that anywayancient-vegetable-10556
06/06/2022, 3:23 PMbitter-ability-32190
06/06/2022, 3:24 PMancient-vegetable-10556
06/06/2022, 3:25 PMbitter-ability-32190
06/06/2022, 3:26 PMbitter-ability-32190
06/06/2022, 3:27 PMancient-vegetable-10556
06/06/2022, 3:27 PMancient-vegetable-10556
06/06/2022, 3:28 PMfile
and resource
dependencies alreadybitter-ability-32190
06/06/2022, 3:28 PMNope! We need support for file dependencies for JVM tests.The proposal tosses (or "unifies" depending on how you wanna look at it) the distinction between
file
and resource
and leaves the user with only one asset type: asset
.ancient-vegetable-10556
06/06/2022, 3:48 PMfile
and resource
targets is extremely significant in JVM land.ancient-vegetable-10556
06/06/2022, 3:49 PMresource
from inside a .jar
at runtime vs how you access a file from the filesystem at runtimeancient-vegetable-10556
06/06/2022, 3:50 PMbitter-ability-32190
06/06/2022, 3:53 PMancient-vegetable-10556
06/06/2022, 4:13 PMancient-vegetable-10556
06/06/2022, 4:15 PMBUILD
files (possibly in how you link them to the target that needs them)ancient-vegetable-10556
06/06/2022, 4:16 PMancient-vegetable-10556
06/06/2022, 4:18 PMfile
and resource
in the first place is a holdover from V1 when Pants was much more JVM focused)bitter-ability-32190
06/06/2022, 4:20 PMbitter-ability-32190
06/06/2022, 4:21 PMfoo_source
depending on a file
is a hint to the foo_test
to maybe materialize it as loose in the test sandbox, but don't include it as a resource when packaging. Instead, let's avoid these little hints and treat everyone equally.ancient-vegetable-10556
06/06/2022, 4:25 PMresource
sometimes needs to be considered as a true dependencyancient-vegetable-10556
06/06/2022, 4:27 PMResource
, or whether it should be opening it as an item from the filesystem, or if both could be necessaryancient-vegetable-10556
06/06/2022, 4:28 PMancient-vegetable-10556
06/06/2022, 4:28 PMbitter-ability-32190
06/06/2022, 4:28 PMancient-vegetable-10556
06/06/2022, 4:32 PMResource
targets are specified as part of the java classpath (i.e. the packaged items available to the JVM).
The File
targets are made available for opening using filesystem commands.ancient-vegetable-10556
06/06/2022, 4:33 PMresource
targets are targets that are semantically significant to the compiler, the packager and to the runtime. Files are just things that code may need to be aware of or able to access at some point.bitter-ability-32190
06/06/2022, 4:35 PMancient-vegetable-10556
06/06/2022, 4:41 PMbitter-ability-32190
06/06/2022, 4:42 PMRight, so it is frequently not appropriate to include files as resourcesWhy is that?
ancient-vegetable-10556
06/06/2022, 4:45 PMpants test
or pants run
which contain internal data, then you definitely don’t want that included as part of the JARbitter-ability-32190
06/06/2022, 4:46 PMbitter-ability-32190
06/06/2022, 4:46 PM<http://MANIFEST.in|MANIFEST.in>
)ancient-vegetable-10556
06/06/2022, 4:47 PMancient-vegetable-10556
06/06/2022, 4:47 PMbitter-ability-32190
06/06/2022, 4:49 PMjava_source
target to allow for such selection. @witty-crayon-22786 sound about right?
One olive branch to extend here is if consuming the resource is relatively rigid in the code, we can add JVM "asset inference" like we do in python, which will automatically determine resource v not resourcewitty-crayon-22786
06/06/2022, 4:50 PMAh, then I suspect we’d need to add a field to thei think where we had left it in the last discussion was that we needed atarget to allow for such selection. @witty-crayon-22786 sound about right?java_source
data_dependencies
field on *_tests
to signal that you wanted loose files, but we hadn’t decided whether it needed to be transitive. haven’t caught up on the design doc, sorrywitty-crayon-22786
06/06/2022, 4:51 PMjava_source
witty-crayon-22786
06/06/2022, 4:52 PMancient-vegetable-10556
06/06/2022, 4:52 PMancient-vegetable-10556
06/06/2022, 4:53 PMwitty-crayon-22786
06/06/2022, 4:53 PMjava_sources
, which cannot themselves consume files, be able to declare a dependency on files… or is that only `*_tests`”bitter-ability-32190
06/06/2022, 4:54 PMwitty-crayon-22786
06/06/2022, 4:54 PMancient-vegetable-10556
06/06/2022, 4:54 PMjar
when you pants run
it, but that’s hard to track, and would make more sense to be declared at the sourceancient-vegetable-10556
06/06/2022, 4:55 PMbitter-ability-32190
06/06/2022, 4:55 PMjava_source
and lets call a spade a spade. data_dependencies
is too vague.
Depending on whether we think files or resources are more prevalent it'd either be (semi-bikeshed) package-asset-dependencies
(a list of asset dependencies to package) or the converse: dont-package-asset-dependencies
(treat these as we did "files" before)ancient-vegetable-10556
06/06/2022, 4:55 PMwitty-crayon-22786
06/06/2022, 4:55 PMwitty-crayon-22786
06/06/2022, 4:56 PMbitter-ability-32190
06/06/2022, 4:56 PMwitty-crayon-22786
06/06/2022, 4:58 PMbitter-ability-32190
06/06/2022, 4:58 PMdescribing what files are consumed by the implementing code makes a lot more sense than describing on the test that may not directly consume itYes and no. The source code isn't actually consuming it though, it's just expecting it to exist in the environment its being run in. Another way of putting it is the source code has a dependency on the runtime environment, which Pants can't control. It's just convenient to declare the dependency on the source as a hint to downstream environments we ourselves create.
bitter-ability-32190
06/06/2022, 4:59 PMpython doesn’t have that middleman either, in that we don’t require a setup.pyNot for PEX, but for
python_distrubution
we do*witty-crayon-22786
06/06/2022, 5:01 PMand being able to mark a data dependency on any jvm source file would probably solve the problem (for tests or otherwise)relatedly, Alonso responded with his use case: https://github.com/pantsbuild/pants/issues/15500#issuecomment-1144003041 … haven’t correlated it with the design yet.
witty-crayon-22786
06/06/2022, 5:03 PMThe normalrefers to the fact that a resource starts out embedded in a jar, so you need to extract it somewhere to use it as a file… that’s a fairly rare case, because 90% of the time you can open a stream and ignore the fact that it isn’t a filebehaviour was enough for that (couldn’t usefile
because you can not run binaries from inside an archive file).resources
witty-crayon-22786
06/06/2022, 5:03 PM