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

jolly-midnight-72759

05/30/2020, 2:12 PM
Is the recommended pattern for writing repo specific plugins still “add path to python_path” and then building a regular python module on that path? For example in
pants-plugins/src/python
I create a module called
awesome_plugin
. This module would need to have
awesome_plugin.register
defined. Is there a pattern that takes advantage of “auto discovery” of plugins that are in the monorepo as opposed to being loaded via pip via an external repository?
h

hundreds-father-404

06/01/2020, 8:43 PM
Hey Raúl! Pardon the delay. Yes, this is still the case. FYI it’s because Pants loads plugins before doing everything else, so we add to the PYTHONPATH for it be discoverable. (I believe this is how it works, might be wrong) Also, no need to use
src/python
.
pants-plugins/awesome_plugin/register.py
works too. Plugins must be written in Python, so
src/python
is redundant
j

jolly-midnight-72759

06/01/2020, 9:20 PM
Good to know.
Has any design work been done for the
pants-plugin universe
? For instance if I create a databricks target for my repo and want to share the plugin, seems the best way is to publish it to pypi. I can't articulate it fully, but it seems like there should be a way to reduce friction to do two things at once with the right pattern (i.e. share the plugin and use it locally).
You've solved the problem I have now though! Thank you.
h

hundreds-father-404

06/01/2020, 9:32 PM
For instance if I create a databricks target for my repo and want to share the plugin, seems the best way is to publish it to pypi.
Yes, that’s the plan. Like how people share Flake8 plugins by releasing a library like
flake8-2020
. Then, users add your plugin to the
plugins
option in their
pants.toml
. I’m not sure how well it works yet for a 3rd party plugin author, though, tbh. Pants releases a couple plugins like
pantsbuild.pants.contrib.node
, but I don’t think people have done 3rd party plugins in a while. That’s something we want to change, in part by making V2 plugins much easier to write than V1 plugins and making them more powerful. We’d love to get to a place like Flake8, where you have dozens of plugins you could choose from.
❤️ 1
4 Views