Is there a plugin for Anltr?
# plugins
b
Is there a plugin for Anltr?
e
Hah! I started Pants long ago in late 2010. @happy-kitchen-89482 joined in a few months later by ... adding support for antlr! Of course that was Pants v1. In the transition to v2 (or earlier - can't remember), that support got dropped.
We're always happy to help writing plugins. If you're motivated to add support, we have some good code generation plugin examples that would be suitable for this.
See here for some detailed discussion of one way of going about this: https://pantsbuild.slack.com/archives/C046T6T9U/p1668030490652699
b
some good code generation plugin examples
Where are those plugins?
What’s the difference between a backend and a plugin? I know there are codegen backends: https://github.com/pantsbuild/pants/tree/release_2.14.0/src/python/pants/backend/codegen
e
Ah, ok. Two words for the ~same thing. Looks like you found the right examples. Technically backends are just plugins that ship with Pants. There are 3rdparty plugins as well. It used to be the case, I'm no longer sure of this though, that a 3rdparty plugin configured via the
[GLOBAL] plugins
list could define the right entry points and get its "backends" registered automatically without also having to list them in the
[GLOBAL] backends
list. That was the only distinction.
b
https://www.pantsbuild.org/docs/enabling-backends If backends and plugins are the same, you reply above should be maintained in the above docs.
I read the first page of my screen for https://www.pantsbuild.org/docs/plugins-overview
The Plugin API is not yet stable
discourages me to write plugins. And I found there are few plugins on Github.
h
Yeah, we hope to stabilize the Plugin API soon, and is much closer to stable than it used to be. But the fact that it isn't completely stable yet is why we like to have most plugins live inside the core Pants repo, so that whoever changes some part of the API also has to change all the things that depend on that part. I think ANTLR support makes sense to live in the pants repo anyway.
Most people who have external plugins have them in proprietary repos that aren't public
Since we now have support for downloading and running JVM tools, and codegen support, I have a feeling that adding ANTLR support would be straightforward.
I can help with that
As John mentioned, that was my first ever Pants contribution, back in 2011
a
There’s some work I’m doing in the
experimental_shell_command
space that will make adding ad-hoc antlr tasks pretty easy
I’m just in the middle of shaving a lot of yaks in order to finish off that particular PR
Just revisiting this thread — here’s a demo of using ANTLR entirely without writing a plugin, that works against mainline Pants (2.16, I guess): https://github.com/pantsbuild/example-python/compare/main...chrisjrn:pantsbuild-example-python:chrisjrn/codegen_with_antlr?expand=1#diff-1[…]4c1ff2f
h
It's pretty epic!
It's exactly what I envisioned being possible with
experimental_shell_command
!
a
not only possible, but also reasonably easy!
b
Awesome, just made a 5-day hackathon on the new project: Liga https://github.com/liga-ai/liga It is using Pants, and we need Antlr support of Pants!
a
Let me know if it works for you! Everything’s pretty new there and hasn’t been well tested beyond my use cases, so getting some feedback would be amazing!
b
https://github.com/liga-ai/liga/issues/54 I created a issue first! Thanks!