I am working on a pants v2 plugin, is there a way ...
# general
p
I am working on a pants v2 plugin, is there a way to get pants to run it without pulling it down from pypi ? i.e. I need something similar to
pip -e ~/project/my-library-folder
but for
pants.toml
backend_packages2.add
@hundreds-father-404
i.e. the plugin is its own GH repo and I want to test it in my monorepo (where I have pants configured)
h
I’m more familiar with how to develop plugins internally to Pants rather than in downstream repositories like Toolchain. So, if it were me, I’d start by developing in
pantsbuild/pants
and then move it over to wherever you want once you get the functionality working To develop a new backend_package in Pants, the main thing you need is a
register.py
in the directory you want, e.g.
pants.backend.python.lint.my_custom_linter
. Then, add
pants.backend.python.lint.my_custom_linter
to
backend_packages2
But, there might be a way to do the
pip -e
thing you’re referring to. Have you seen https://www.pantsbuild.org/howto_plugin.html already?
p
I looked at those docs... but I don't think they cover my use case (which might or might not be common). i.e. they suggest I use pants on the pants plugin project, which is fine... however, there will be a minimal amount of code in that repo... so it doesn't really provide a good way to test the plugin against a the a target large mono repo.... As for developing the plugin in the pants monorepo or in my monorepo, this will work fine for the first iteration... but as I release this plugin to pypi and want to iterate on it.... this becomes somewhat cumbersome. i.e. it seems to me that there is no reasonable dev flow for developing standalone/external plugin for pants that live in their own repos since those can't be installed locally and use from a monorepo that is using pants....
h
You could use
PYTHONPATH
to point it to your repo. See Toolchain’s
./pants_from_sources
script for how we load Pants plugins as loose source plugins, rather than pulling them from PyPI. For example, it looks like we register
../pants/contrib/awslambda/python/src/python
on
PYTHONPATH
and then we’re able to use
pants.contrib.awslambda.python
in
backend_packages
👍 1
h
We must have a solution for in-repo plugins, at least no?