https://pantsbuild.org/ logo
r

refined-dusk-58376

12/17/2020, 9:07 PM
I wanted to link this for people that are having issues with the development process. One of the things I determined at some point was that for monorepos it's helpful to separate each project into their own workspace. I plan on writing some tools for working with Pants at some point, though the work I have on my plate is a bit intense. I can't do it immediately until certain obligations are met. https://marketplace.visualstudio.com/items?itemName=folke.vscode-monorepo-workspace
👀 1
@happy-kitchen-89482 So, here's an idea. IDK if you guys have a Pants VSCode extension that you're building, but I would totes would love if you would do it openly.
I want to develop an extension, but I'd prefer to: 1. Not clash with the development you guys are doing. This also extends to doing useless work. 2. Ensure the solutions I come up with are solidified 3. Ensure the solutions are used.
f

flat-zoo-31952

12/17/2020, 9:18 PM
This seems to be for the case where you have multiple well-defined projects sharing a single repo and probably a lockfile. I'm not sure my projects break down quite that easily. But I'll give this a try and let you know what I think
h

happy-kitchen-89482

12/17/2020, 9:18 PM
Hi Kevin, thanks for the link and for offering to come up with solutions!
I don't use VSCode myself, so I'd need to do more learning before expressing opinions...
But @witty-crayon-22786 has had some thoughts about it I think?
r

refined-dusk-58376

12/17/2020, 9:20 PM
I already came up with a CLI to manage the pants monorepo. I plan on iterating on it in the near future, though I can foresee having a system in place to make it so the user won't have to think would be hella useful.
h

happy-kitchen-89482

12/17/2020, 9:20 PM
We would definitely appreciate contributions from a user such as yourself who has actual use-cases in mind.
💯 1
r

refined-dusk-58376

12/17/2020, 9:21 PM
To Pants.build?
Or a plugin?
h

happy-kitchen-89482

12/17/2020, 9:21 PM
I will say that Pants does support multiple source roots (https://www.pantsbuild.org/docs/source-roots)
Is that what you mean by multiple worksapces?
I prefer to not work that way personally, but each repo can make their own decision.
I guess it would be great if we could come up with a way to support VSCode and other IDEs without requiring a particular repo layout.
r

refined-dusk-58376

12/17/2020, 9:23 PM
Yeah ... that was the goal at some point
h

happy-kitchen-89482

12/17/2020, 9:23 PM
Re core or plugin, everything is a plugin these days, but I can imagine this being in the core repo
Better IDE support is a much-requested feature
We're still figuring out what that means for the various leading IDEs out there
r

refined-dusk-58376

12/17/2020, 9:24 PM
For the CLI I've set it up to detect the pants config file in python then I use that config to do things like find the source routes
f

flat-zoo-31952

12/17/2020, 9:25 PM
what i understand "better IDE support" to mean for me is a way to convince my IDE to use pants for everything it wants to do with my project
r

refined-dusk-58376

12/17/2020, 9:26 PM
PEX file format is godsend for having a CLI tool that can go into the path of any Unix OS.
@enough-analyst-54434 I feel that
f

flat-zoo-31952

12/17/2020, 9:27 PM
i think IDEs are often coded with certain assumptions about being the orchestrator of tools within a project (VS Code is pretty flexible with its plugins and all, but it still assumes you can configure everything to work with it), but when you start using pants you start to realize its a superior orchestrator and you want your tooling to work through it, rather than around it
r

refined-dusk-58376

12/17/2020, 9:27 PM
The biggest thing I wanted was the capacity to add/remove projects between Rust and Python. Then have autocomplete work with no problem.
Yeah ... there's some thoughts I have around that. Autocomplete and quick commands (macros in VIM) are bae,
f

flat-zoo-31952

12/17/2020, 9:30 PM
what do you mean by "add/remove projects between Rust and Python"?
r

refined-dusk-58376

12/17/2020, 9:33 PM
To answer your question. I wanted to be able to start a new project inside of the monorepo (think using
poetry new
) or
cargo init
and be able to link the projects I have while developing them so I have autocomplete for them.
I couldn't live without autocomplete honestly. I have a condition that makes it so I have a short-term memory of a goldfish.
When writing python, it's kind of hard to manage cross-project dependencies.
For example:
(Editing for Formatting) 1. I have a bunch of separated util libraries that needed to be consumed by a bigger project. I was struggling with both installing the util projects into my bigger project. 2. I was also having issues with creating build processes and plugins for the code itself. It took me a few times of reading the tutorials to understand what I should be doing there, though I figured the actual steps for going about doing the most common things should be pretty well defined. 3. What I've come to do is rely on the DepHell project to create a
setup.py
then install an editable version of the micro-projects I'm including in a bigger project using their installation method.
Cargo has cargo-workspaces to help with that. Python doesn't
Might as well add some other things too: 1. While I'm trying to isolate the development of projects I want to not have to look at the other folders that are out there. Having some sort of isolation has been beautiful for development itself. It both helps for indexing and gives mental clarity. 2. For the isolation problem I have above, I use VSCode's multi-root workspaces. That surprisingly helps with project specific autocompletion (which is also a problem). I can choose a Python virtualenv per root meaning the completion I have doesn't bleed immediately over from other projects.
f

flat-zoo-31952

12/17/2020, 9:58 PM
okay for many of these goals, i think you don't really need to think of these things as "multiple projects" with pants, as you can kinda just let dependency inference and build graph awareness work for you
w

witty-crayon-22786

12/17/2020, 9:59 PM
@refined-dusk-58376: i’m just finishing lunch and going into a meeting, but this is a really, really interesting space, and i think that we’d love to support work happening on a workspace concept.
f

flat-zoo-31952

12/17/2020, 9:59 PM
(this is how i use pants anyways, and it's really the killer feature for me, but i'm not everyone)
r

refined-dusk-58376

12/17/2020, 9:59 PM
VSCode doesn't see it that way
Which was kind of frustrating when I got started
f

flat-zoo-31952

12/17/2020, 10:00 PM
i just let vs code see the whole source tree
w

witty-crayon-22786

12/17/2020, 10:00 PM
https://docs.google.com/document/d/1sr1O7W9517w8YbdzfE56xvDb72LafK94Fwxm0juIRFc/edit# is related to this, but not identical. a Resolve might be larger than a single “project” or “target”, but smaller than the entire repository.
if you workspace is entirely contained within one Resolve, then it is consistent from a typeahead perspective
e

enough-analyst-54434

12/17/2020, 10:02 PM
An idea from long long ago is to integrate pants knowledge of your "projects" and their dependencies with
git sparse-checkout
to implement a (strawman name)
./pants view <files or targets>
f

flat-zoo-31952

12/17/2020, 10:02 PM
makes sense, and i could see the desire to have "workspaces" that are aggregations of targets, probably limiting that to trees for simplicity's sake
r

refined-dusk-58376

12/17/2020, 10:02 PM
Yeah ... it's kind of strange while developing that way for me. I have a condition that kind of reduces my mental filter. Too much information turns into a problem
e

enough-analyst-54434

12/17/2020, 10:03 PM
Perforce + Blaze (Bazel) could do this and it was useful for all the reasons noted here so far.
f

flat-zoo-31952

12/17/2020, 10:04 PM
me too, but my coworkers have a condition where they have trouble drawing the lines between "projects" well and end up making bad design decisions about those boundaries that affect us all down the line
r

refined-dusk-58376

12/17/2020, 10:04 PM
LOL
f

flat-zoo-31952

12/17/2020, 10:05 PM
maybe a better way to express what i mean is that pants allows me to delay the decision to treat some code as "library" code and other code as "application" code until very late in the process
it's all
python_library()
to pants for the most part, until you define a binary target
this does require some discipline with how i do my imports, but it's inspectible with tools like
./pants dependencies
& co
r

refined-dusk-58376

12/17/2020, 10:07 PM
I'm going to have to create a practice project where I write a DSL. I might give pants a first run.
w

witty-crayon-22786

12/17/2020, 10:07 PM
for the purposes of IDE integration, having separate/independent definitions of “what you load to work on a particular workspace/subset-of-the-repo” is a pretty powerful concept… which seems to be the thrust of https://marketplace.visualstudio.com/items?itemName=folke.vscode-monorepo-workspace
f

flat-zoo-31952

12/17/2020, 10:08 PM
it does, but that one also seems limited to a tree-based view of it
r

refined-dusk-58376

12/17/2020, 10:09 PM
I have a bunch of problems that need to be standardized, and a DSL is basically the only way I see as a means to solve the problems.
f

flat-zoo-31952

12/17/2020, 10:09 PM
if that notion could be expanded to a DAG, i'd see a hell of a lot more utility in it
w

witty-crayon-22786

12/17/2020, 10:10 PM
@flat-zoo-31952: right. i think that idea is that you pick and choose the “roots” of the import, and then their dependencies are imported as well?
f

flat-zoo-31952

12/17/2020, 10:10 PM
perhaps? it errored on me when i tried it, so i can't really tell though
but that's what i mean for IDE integration being about making the IDE ask pants for things like this
because pants knows how to answer things like "what portions of this codebase do i need for this development task" better than any IDE does
r

refined-dusk-58376

12/17/2020, 10:14 PM
Dope. I love that there's discussion about this. I'd say go for a bare minimum, fork the existing plugin (one linked above) and have the people on the team that use VSCode create an extra feature every now and then.
Generally, the
pants.toml
file will tell where the sources. People could select how to interpret how they go underneath those sub folders
When my schedule actually clears up the plan was basically to fork the VSCode extension and try getting it to work with Pants
🔥 1
3 Views