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

bitter-ability-32190

12/20/2021, 2:44 PM
Should I prefer granular per-dir build files, or one top-level one with big fat globbing. ๐Ÿงต 1. First option is what
tailor
would have me use. One
BUILD
file in each directory that matters. โ—ฆ Pros: Granular. Pants internals kind of assume this pattern (so target names are sane, etc...). โ—ฆ Cons: Still boilerplate-y (MUCH less so than say, Bazel. But still have N files which just repeat
python_sources()
,
python_test_utils
,
python_tests
over and over). 2. Second is one
BUILD
file in the "root" which has nested globs for each (E.g.
sources=["***/**.py", "!**/conftest.py", ...]
) and then I can override when necessary at the directory level (assuming that works ๐Ÿค” ) โ—ฆ Pros: Minimal boilerplate โ—ฆ Cons: Less granular. Pants internals don't assume this (the target name of the generator is funny looking when printed) Q: Is pants smart enough for option 2 to not have double ownership? Can it be taught to be? Q: What considerations should be made about cache invalidation? If I edit the top-level file in #2, do I bust any caching? Q: For option 2, can I improve the names that get spit out? Does the "generators-are-not-targets" proposal help this case?
๐Ÿ‘€ 1
h

hundreds-father-404

12/20/2021, 2:47 PM
As it stands, we recommend one target per directory. What
tailor
does. See https://www.pantsbuild.org/docs/targets#target-generation and https://github.com/pantsbuild/pants/issues/13488 But we think this isn't flexible enough, you have to repeast yourself too much: https://github.com/pantsbuild/pants/issues/13767
๐Ÿ‘€ 1
b

bitter-ability-32190

12/20/2021, 3:04 PM
(added my two cents)
โค๏ธ 1
For option 2 though, does Q1 have an answer? I'd prefer a top-level
BUILD
while I'm only using Pants for
fmt/lint/check
as to not scare my devs by adding a bajillion
BUILD.pants
files
h

hundreds-father-404

12/20/2021, 3:07 PM
It is not smart enough to handle double ownership, and I suspect you'd get a rule graph cycle if you tried querying what targets already exist inside a target generation rule. Since that's cyclical to compute
b

bitter-ability-32190

12/20/2021, 3:07 PM
I'm afraid to query my top-level generator ๐Ÿ˜ฌ
๐Ÿ˜… 2
c

curved-television-6568

12/20/2021, 3:08 PM
Generate-Generators from top level ๐Ÿ˜ .. would prob still be cyclical though..
h

hundreds-father-404

12/20/2021, 3:09 PM
Related is that currently the only way to parametrize config is to create multiple targets for the same entity. Thus, multiple targets is currently a first-class concept But I'd love to replace that with something better. This parametrization problem has stymied many past attempts to simplify targets. Feedback welcomed in https://github.com/pantsbuild/pants/issues/13882
๐Ÿ‘ 1
b

bitter-ability-32190

12/21/2021, 4:23 PM
Should I be worried that Option 2 seemingly works without cycles? ๐Ÿ˜ฌ
2 Views