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

loud-laptop-17949

01/18/2023, 9:52 PM
Has anyone found or built a tool for automated editing of pants BUILD files? I have tried bazel's buildozer but it can't seem to work for me.
h

high-yak-85899

01/18/2023, 9:52 PM
I configured vscode to do it for me
I told vscode to treat
BUILD.pants
code as python (starlark, but good enough) and then it is subject to the same rules as the rest of our repo.
b

bitter-ability-32190

01/18/2023, 9:54 PM
Buildozer works surprisingly well for editing them
l

loud-laptop-17949

01/18/2023, 9:56 PM
@high-yak-85899 i am mostly trying to build some automation for larger-scale refactoring, so I don't know if that would help me
h

high-yak-85899

01/18/2023, 9:57 PM
There are commands within pants goals to do large scale formatting already
l

loud-laptop-17949

01/18/2023, 9:57 PM
@bitter-ability-32190 I haven't gotten it to work because we use a non-standard build file name (BUILD.pants) and buildozer can't seem to handle that
I am not doing formatting, i am trying to edit files
h

high-yak-85899

01/18/2023, 9:58 PM
Gotcha
e

enough-analyst-54434

01/18/2023, 10:00 PM
@loud-laptop-17949 have you rejected the obvious rename dance scripted up as a sandwich around buildozer?
b

bitter-ability-32190

01/18/2023, 10:01 PM
There's buildifier and buildozer. One formats and one edits the editing one works well. I don't remember having a naming issue and we use BUILD.panta
f

fresh-cat-90827

01/18/2023, 10:15 PM
I have tried bazel's buildozer but it can't seem to work for me.
I used
buildozer
only for a simple refactoring (like setting certain fields on and off), but it looks to be very powerful based on the docs and sample usage calls. Maybe you could share what you are trying to edit and we could experiment?
Copy code
$ buildozer 'set skip_yapf True' 'set skip_mypy True' ///...:%python_sources
$ buildozer 'set skip_yapf False' projectdir/subdir:%python_sources
l

loud-laptop-17949

01/18/2023, 11:43 PM
@fresh-cat-90827 have you gotten that to work if your BUILD files have a different name/extension?
f

fresh-cat-90827

01/18/2023, 11:44 PM
oh, let me give it a try. I've used the standard BUILD file name
l

loud-laptop-17949

01/18/2023, 11:46 PM
@enough-analyst-54434 yeah I thought about renaming all the files and may end up there, but would prefer to avoid it. also though about dealing with the issues that forced us to use
.pants
in the first place (we have a bunch of random shell scripts called
build
)
f

fresh-cat-90827

01/18/2023, 11:47 PM
yes, I remember those funny times with the conda related build files named
build
!
e

enough-analyst-54434

01/18/2023, 11:47 PM
Blaming the wrong thing! build is fine, macOS is not.
💯 1
l

loud-laptop-17949

01/18/2023, 11:47 PM
ha yeah that's part of the problem
f

fresh-cat-90827

01/18/2023, 11:49 PM
case-insensitive funny times 😄
so no, I cannot run
buildozer
on anything else than BUILD, I am afraid. Folks complained about not being able to configure it, but they have only fixed it for BUCK 🙂 https://github.com/bazelbuild/buildtools/pull/58/files
can't pass via stdin either - was thinking about a Bash for loop or something and piping
e

enough-analyst-54434

01/18/2023, 11:50 PM
That looks extremely easy to fork and go install then.
f

fresh-cat-90827

01/18/2023, 11:51 PM
FWIW v
l

loud-laptop-17949

01/18/2023, 11:59 PM
looks like I am going to have to fork buildozer to get what I want
f

fresh-cat-90827

01/19/2023, 12:04 AM
it would be awesome to have it configurable, but this may take a while...
i.e. contribute upstream
6 Views