https://pantsbuild.org/ logo
c

creamy-airplane-38079

05/26/2022, 3:25 PM
Hi team, does anyone know of a library ( hopefully in python) that allows you to parse the Starlark BUILD file ? I am looking at some helper functionality to automatically edit/add some target definitions in existing BUILD files.
1
b

bitter-ability-32190

05/26/2022, 3:25 PM
FWIW Pants' BUILD files are straight-up Python, not Starlark. That being said, look into Bazel's Buildozer. It'll be comptaible
👍 1
h

hundreds-father-404

05/26/2022, 3:36 PM
for adding target definitions, you might want to hook into the
tailor
goal also
if you're doing something more permanent, you can add a "fixer" to
update-build-files
to make whatever changes you want. It's a very flexible API -- takes in the BUILD file contents as a string and then you return back what you want
c

creamy-airplane-38079

05/26/2022, 3:47 PM
thanks for the suggestions! 🙂
❤️ 1
w

witty-crayon-22786

05/26/2022, 4:39 PM
c

creamy-airplane-38079

05/26/2022, 6:49 PM
ah! awesome thanks for the link, that looks like what I am looking for
w

witty-crayon-22786

05/26/2022, 6:50 PM
(thanks to @fresh-cat-90827!)
❤️ 1
4 Views