https://pantsbuild.org/ logo
#general
Title
# general
r

rough-vase-83553

09/10/2022, 7:28 AM
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

refined-addition-53644

09/10/2022, 10:34 AM
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

bitter-ability-32190

09/10/2022, 7:31 PM
Macros are the equivalent
r

rough-vase-83553

09/13/2022, 4:41 PM
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

busy-vase-39202

09/20/2022, 7:20 PM
You could open an issue! Helping us understand a request and the use cases motivating it is a valuable contribution.
w

witty-crayon-22786

09/20/2022, 8:23 PM
i believe that
__defaults__
should work with
parametrize
? if not, thatโ€™s a bug
๐Ÿ‘€ 1
r

rough-vase-83553

09/20/2022, 8:24 PM
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

witty-crayon-22786

09/20/2022, 11:21 PM
ah: yes please. sorry for the trouble: i thought that we had already done that.
๐Ÿ‘€ 1
r

rough-vase-83553

09/20/2022, 11:36 PM
w

witty-crayon-22786

09/20/2022, 11:40 PM
thank you!
๐Ÿ™Œ 1
b

busy-vase-39202

09/20/2022, 11:44 PM
Glad you brought this to our attention!
r

rough-vase-83553

09/20/2022, 11:45 PM
Anytime. Thanks for the quick response!
b

busy-vase-39202

09/20/2022, 11:52 PM
โค๏ธ 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