Is there anything I should look out for for when u...
# general
s
Is there anything I should look out for for when using the 2.0.0dev6 version?
h
Hello! Awesome to hear. If you’re already using 1.x, check out https://www.pantsbuild.org/v2.0.0/docs/how-to-upgrade-pants-2-0 You may want to wait until the dev release on Monday tbh. dev6 has some known issues, namely a major regression to the startup time and clunky handling of
__init__.py
files if you haven’t gone all in on using the new feature of dependency inference.
s
I haven't used 1.x. Btw. where do I find the python API docs? I'm writing a plugin and it's a bit hard to see what's available.
I'm diving into the python sources on github now to see that.
h
Ah cool! See https://www.pantsbuild.org/v2.0/docs/plugins-overview. They’re still a WIP, some core parts are missing. I’ve been working on docs the past week and am hoping to finish next week. Mind sharing about what your plugin is that you’re working on? We’d be really happy to help you out with it, including pair programming. Beyond us wanting to help users, it’s also valuable feedback because the Plugin API hasn’t been very publically consumed yet.
s
Another question: How do I get my IDE to recognize the pants imports in plugins and find the code for them?
h
s
Yes, I see those, I mean more like generated docs. The python code seems to be very well documented
h
Yeah, no generated references for the Plugin API. For now, the best bets are the guides in the docs + the docstrings in source code.
s
Yep, I'm looking at those right now. I think a generated reference documentation would be cool!
👍 1
h
How do I get my IDE to recognize the pants imports in plugins and find the code for them?
See the last sentence of https://www.pantsbuild.org/v2.0/docs/plugins-overview#tip-set-up-your-plugin-with-the-python-backend about how to set up a venv. The example plugin has a script you can copy under
build-support/python/setup_venv.sh
👍 1
s
Mind sharing about what your plugin is that you’re working on?
I'm just trying to invoke
cargo
to compile rust binaries for me. I don't need it to be deeply integrated, just kind of take the rust source directory, invoke the command and output a binary, that I can depend on for another target.
I hope that's straight forward to do
w
@some-farmer-97614: it should be feasible, yea. the primary thing to grapple with is just that all file dependencies to the process need to be specified, because it will be executed in a sandbox directory
meaning knowing all of the files that cargo will consume relative to where it is executed, and specifying them as inputs to the process
it’s also best if rules don’t assume that a tool is already installed on the user’s machine as well, so having a separate process that bootstraps cargo from rustup or w/e is a good idea for a well behaved rule. totally fine to do it after everything else is working though, and just locate it on the PATH until then.
h
Eh, likely fine to assume it’s installed on the machine. Their plugin doesn’t need to be as general as Pants’s own backends. Still a WIP, but you’d use
BinaryPaths
to discover where cargo is installed on their machine in a generic way: https://www.pantsbuild.org/v2.0/docs/rules-api-installing-tools Even simpler is to assume a fixed absolute path, like
/usr/bin/cargo
or wherever. While iterating, I recommend doing that. Then generalize when relevant.
w
cc @aloof-angle-91616, who has done some work in this area. since he posted his patches, we’ve added a way to choose a stable cache directory, which would be a good place to put CARGO_HOME:
Process(append_only_caches=..)