one last question for me for today (mayhaps :sweat...
# general
f
one last question for me for today (mayhaps 😅) i’m looking to add support / dependency inference for a language which has some fairly strict rules regarding imports — i’ll probably break my neck in trying to do so, but — is there any good examples i should be looking into for understanding what is needed there? .. i guess shell might not be the worst starting point, to try and understand how that plugin is structured, and where the
:sausage:
is made … 😆
w
Which language? That might help direct
f
jsonnet
🙌 1
h
No limit on questions here 🙂 we like helping, and it's also useful feedback for us where we can improve docs etc Re dep inference plugins, this is one of the most common to implement What Pants version also? The API changed a little in 2.14
f
2.12 i think — but i’m happy to work on 2.14 if that’s a release slated for release within the near future
h
but i’m happy to work on 2.14 if that’s a release slated for release within the near future
Probably not for another few weeks. So probably better to target 2.12 or 2.13, and then follow our plugin upgrade guide when 2.14 is closer to stable
w
Required reading - excellent doc about adding a language (or parts thereof): https://docs.google.com/document/d/1S_gMq2svApYH1yorkyQYsYRO6VbZN-N7eFyfd2TKkzg/edit As someone newer to the dep inference side, I found it easiest to understand whichever language(s) I was most familiar with. So, for me, that was following python, C++, and Kotlin
f
that certainly makes sense
thanks for the doc pointer
h
so how most languages do dependency inference is: 1) Create a mapping of <imported entity> -> Pants target for it 2) for each target, parse out its imports. Sometimes you can use regex, sometimes run a parser program, sometimes write your own parser 3) look up the parsed imports in the dictionary from step 1. Use standard Pants code to handle if there is ambiguity I think Shell is likely the easiest to follow along because it does not have complex things like "resolves" (lockfiles) https://github.com/pantsbuild/pants/blob/2.12.x/src/python/pants/backend/shell/dependency_inference.py
<imported entity>
e.g. file name, Python module, etc
👌 1
f
do you use the site as api docs/reference, or are there some good resources in that regard i should know about?
h
Not yet for plugins. For plugins, we have guide style documentation at https://www.pantsbuild.org/docs/plugins-overview, which is a good starting point. And then (unfortunately) for now looking at code examples in pantsbuild/pants is likely the way to go Note that pantsbuild/pants uses the exact same Plugin API you're using We really want to revamp the super stale example-plugin repo with some new things we've learned about writing docs, but haven't had the bandwidth
👍 1
f
appreciate the swift answers!
❤️ 1