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

flat-zoo-31952

08/31/2022, 7:05 PM
I'm finally splitting up a big-ol' BUILD file with lots of recursive targets and overrides. Is there some automated tooling to help with this? Like maybe we could steal some Bazel tools. Or will I need to just need to process this myself?
w

witty-crayon-22786

08/31/2022, 7:08 PM
deleting the file and then running
./pants tailor ::
should do 95% of it?
or, at least deleting all of the recursive targets
f

flat-zoo-31952

08/31/2022, 7:15 PM
yeah... but I want to move the extensive overrides to the new BUILD files 😕
./pants peek //:
gives me json for everything defined in that file, but it's a bit much
w

witty-crayon-22786

08/31/2022, 7:23 PM
yeah... but I want to move the extensive overrides to the new BUILD files
ah.
f

flat-zoo-31952

08/31/2022, 7:23 PM
I think i'm just gonna
eval()
the build file with the generators aliased to something that collects the data... then I can process the overrides with pathlib, add those build files first, then do
./pants tailor
to fill in the normal stuff
b

bitter-ability-32190

08/31/2022, 7:25 PM
Bazel's
buildozer
might help. I've used it on Pants BUILD files for automated refactoring: https://github.com/bazelbuild/buildtools/blob/master/buildozer/README.md
👀 1
b

busy-vase-39202

08/31/2022, 8:35 PM
f

fast-nail-55400

08/31/2022, 9:59 PM
would Jedi (https://jedi.readthedocs.io/en/latest/#) be useful? It powers some Python LSP servers and other tools.
f

fresh-cat-90827

09/01/2022, 7:31 AM
f

flat-zoo-31952

09/01/2022, 5:09 PM
This stuff would be interesting but the hard part is merging overrides... evaling the build file is pretty easy, as you can just pass globals for all the target types it uses and replace them with a function that collects the kwargs. I'll post a snippet when I'm done
👍 2
6 Views