So I've had a chance to do a deep dive and get a b...
# general
r
So I've had a chance to do a deep dive and get a basic project setup. I was able to figure out the development flows with VSCode and now I'm trying to solidify it by creating my very own CLI tool and a complementary plugin.
What would be the quickest win I could have when creating my own plugin?
h
Cool! The most important part of adding a Pants plugin is figuring out what you want it to do, and how you would run it without Pants. For example, often Pants is simply running a subprocess like
black
or
pytest
What type of functionality are you hoping to add?
r
I'm looking to add a way to manage the dev workflow in python. What I want to do is initiate a root poetry virtualenv then take all of the sub projects (identified by
pyproject.toml
) then install a dev version of the sub libraries on the root library
I've already done the steps manually to know how to do it. Now I just need to do it using a plugin. Edit: I plan on using it with a complementary plugin to generate builds using the macro methodology.
What I'm having problems with is just getting the bash plugin to work in my project.
h
Okay, I’m not totally following how that works. What is the end “product” you’re creating? A unified virtualenv, managed by Poetry, which has all subprojects combined into one venv?
What I’m having problems with is just getting the bash plugin to work in my project.
Hm, what types of problems? Happy to help with that
r
Something that will let me have instant editable auto-completion in VScode. Autocompletion might not be the best word. Just something my editor recognizes without me having to do so much work. My team could develop faster that way.
h
Okay, so IDE support is the main motivation. Got it. That’s one of the main votes for the Q4 prioritization we recently did, and it’s likely we’ll be adding better IDE support too soon. Pants doesn’t yet have first-class support for Poetry, but we want to add it. Are you envisioning continuing to use Poetry, and then running
poetry export
to convert into requirements.txt files understood by Pants?
r
Yup
The way I see it, it might be a possibility to create a bunch of small
requirements.txt
files to help code move into production.
h
Does this venv include your first-party code, or only third-party requirements? Are you using codegen (protobuf) also?
r
First party subdirectories
h
It might be a possibility to create a bunch of small requirements.txt files to help code move into production.
Yeah, Pants supports multiple requirements.txt. For each requirement.txt, you would have a BUILD file in the same directory with the macro
python_requirements()
, which converts each into a
python_requirement_library
target However, Pants currently only supports a single constraints file. A big feature request for Q4 is to support multiple
r
Not going codegen immediately, though I will do some form of it soon for the same kind of repo.
So ... right now I'm not struggling with high level details. I'm mostly struggling with getting plugged in tasks working.
h
Okay. And what would be the workflow here? For example, would a dev run something like
./pants export
or
./pants vscode
periodically, and it will run all these steps? Note that this would be manual still
I’m mostly struggling with getting plugged in tasks working.
What’s going on with the bash plugin not working?
r
How would I check to see if the code is registering outside of running the full plugin?
Is there anyway to check if something is getting registered?
h
./pants help targets
will show if the target types are showing up
./pants help subsystems
should show some new subsystems like
shfmt
and
shellcheck
(that last command was added in Pants 2.1.0)
r
I see
Yeah, I'm trying it on the example code base and it's working
👍 1
That's what I thought. I'm just struggling to get to working on mine.
I'm going to reduce the number of variables I've changed and see if that helps it.
h
Some things to double check: - you’ve set
pythonpath
to the “source root”, e.g. if you have
pants-plugins/bash/register.py
, and in your code you use
import bash.register
, then set
pythonpath
to
pants-plugins
- you’ve activated all the backends in
backend_packages
. In the above example, you would activate
bash
r
I just pulled the whole example code base and config over and that worked out
I'm wondering what the conditions are for failure though
h
What do you mean by that?
r
I was wondering what was different from my config and you guy's.
From what I see the key different was that I was missing the plugin paths inside of the
backend_packages
h
That would do it - even though the plugin exists, it wasn’t being activated
r
Oooooo
Well ... lesson learned. I'm glad to have figured that out. I'm going to add that into my CLI. Automatically adding these things so I don't have to think about it.
Can't wait to see what your IDE experiences will be like. If I have something good I'll definitely publish my plugin
❤️ 1
h
That’d be awesome! With the Q4 prioritization, that’s only what the current team of committers is planning to work on - we always love and welcome contributions, and it’s the best way to get new functionality into Pants sooner
Automatically adding these things so I don’t have to think about it.
Pants v1 was closer to this type of automatic registration. We registered all the builtin backends by default. But we found it was a really bad UX, as people wouldn’t know to opt-out so they would have irrelevant things like JVM support activated even if they never used it. As a design choice, backends are always opt-in in v2
r
Also, how did you guys write your parallel client with async python exposure? I'm soon to write something similar for a client-server networking application (python exposure with Rust internals). I've been pondering how to make one a reality and I'm seeing one stare me in the face.
h
r
Dank
I'm going to glance through it for 20 mins tonight then get back to this pipeline
Wow ... I'm reading this stuff and man it's cool. 🙂
❤️ 1
h
Rust has been awesome! And it’s a nice mix where logic is easy to write because it’s typed python 3, but performance critical operations happen in Rust
r
Definitely man. I'm going for the combination for the same reason. People don't care about what's underneath the surface, but they will know the difference. It's what's drawing me to the language combination, and even more so a project like this.
It'll definitely be some work to make this thing more beginner friendly. I'm currently writing down outlines and experimenting for a few more bits before I jump into Rust code.
I would definitely recommend a cli and an extension (for VSCode because of its massive audience). The combination would allow people to pick their poison for their workflow.
I know some people that never touch their mouse (gods of men)
h
Sounds good. Contributions also always welcome for Pants if you end up hacking on Pants vs your new tool. There are tons of things we’d love help with
r
I'll probably hand over my poetry workflow if I know it works.
💯 1
Going to start a new thread about that.
h
Awesome. Check out the #plugins channel if you’re not in it yet
r
Definitely will. There's a diamond in the mud here. I have a massive workflow that I'm going to need to ensure is sturdy for a bit. It'll involve Kubernetes, Databases, some Rust and serverless (openfaas, nuclio, etc) and what not. Having a build tool configured to help me keep steady will be a life saver a week or so from now.