Does Pants have any equivalent to Bazel's `defs.bz...
# general
r
Does Pants have any equivalent to Bazel's
defs.bzl
concept, particularly variables that can be shared across BUILD files? I have a use case where many lockfiles might be resolved for every package in a library project. I'm hoping it can be done through something like
resolves=parametrize(library_users)
rather than copying
resolves=parametrize(["resolve-1", "resolve-2"...])
in every target.
Seems that would be macros.
r
I donโ€™t know much about Bazel but pants has introduced
___defaults___
to handle such use-case. https://github.com/pantsbuild/pants/pull/15836
๐Ÿ‘€ 1
b
Macros are the equivalent
r
Ah darn,
__defaults__
might have been the right move here if it were not for the parameterization. I don't suppose Pants team could add support for that use case ๐Ÿ˜… .
b
You could open an issue! Helping us understand a request and the use cases motivating it is a valuable contribution.
w
i believe that
__defaults__
should work with
parametrize
? if not, thatโ€™s a bug
๐Ÿ‘€ 1
r
Oh really? I'll give that a try. I didn't see any specific examples in the docs but didn't disprove support. Mb
@witty-crayon-22786 I tried it and it doesn't work unfortunately.
Copy code
$ ./pants update-build-files ::
19:18:21.00 [ERROR] 1 Exception encountered:

  InvalidFieldTypeException: The 'resolve' field in target build-tools#__defaults__ must be a string, but was `parametrize(['meta']` with type `Parametrize`.
Should I file a bug / feature request ticket for this? It might require some architectural changes depending on when the parametrize expansion occurs relative to default resolution.
w
ah: yes please. sorry for the trouble: i thought that we had already done that.
๐Ÿ‘€ 1
r
w
thank you!
๐Ÿ™Œ 1
b
Glad you brought this to our attention!
r
Anytime. Thanks for the quick response!
b
โค๏ธ We aim to maintain a welcoming and responsive community. It's important to us that using Pants be primarily a source of developer joy, not one more delay slowing down the dev's day.
๐Ÿ™Œ 1
๐Ÿ‘ 1