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

loud-laptop-89838

01/06/2023, 4:00 PM
I'm curious what is the typical approach to managing requirements in a pants monorepo. In particular, a new requirement. So let's say I open a python file and I want to use a new library. Pants hasn't seen it before, so it won't be in my `./pants export`ed venv. It's also not in my requirements file. So do I add a line to my requirements file, then
export
, then my interpreter should be updated? Just wondering what everyone is using as a workflow. And what about separating requirements for different areas of the repo? E.g. do you have a top level requirements file, then one in each module? Are you using
pyproject.toml
? Again, in each module? Or just one for the whole repo.
e

enough-analyst-54434

01/06/2023, 4:02 PM
If you don't have a strong reason for willy-nilly requirements, I suggest clamping down. Only if you absolutely must entertain different source depending on different version of 3rdparty should you go there.
l

loud-laptop-89838

01/06/2023, 4:02 PM
You're saying just keep it at the top level.
e

enough-analyst-54434

01/06/2023, 4:03 PM
I think physical organization is overblown. But sure. The key is 1 set.
l

loud-laptop-89838

01/06/2023, 4:04 PM
If that's the case, is there a strong reason to use an exported venv over the normal venv? If you only have one set of requirements, they will essentially be the same and doing export just adds a step.
e

enough-analyst-54434

01/06/2023, 4:05 PM
I'm not sure how an exported venv is related. What do you use it for? An IDE?
l

loud-laptop-89838

01/06/2023, 4:06 PM
Yeah. In my IDE.
e

enough-analyst-54434

01/06/2023, 4:07 PM
Ok. I personally just re-export now an again when I notice a missing dep in the IDE. That's all I use it for though.
Stepping back, IMO, this really has nothing to do with code or monorepos. Just don't introduce degrees of freedom when you don't need them.
FWIW - Pants totally aside, This is the same dance I do for Rust. Add a dep to Cargo.toml, refresh the IDE.
Or, if I'm lazier, I don't do that and just read the rustdoc well and type without assistance. That takes both laziness and a bit of bravery, but works. I only do it sometimes.
l

loud-laptop-89838

01/06/2023, 4:12 PM
That's fair. I was asking in the context of monorepos because they would tend to have more dependencies. But if I understand your general point it is that you should have one venv and list of deps if you can get away with it. If you get into a situation where you have conflicting deps then you need to split them. But only split if you absolutely have to. This would apply to a monorepo or multi repo.
e

enough-analyst-54434

01/06/2023, 4:13 PM
Yes, exactly.
As to requirements.txt or pyproject.toml, it totally depends. I use requirements.txt when I need interop with simple CLI tools. The toml gets in the way of that. If I don't have that constraint and I actually publish the project, then maybe pyproject.toml, but really only if I need to publish it.
If it can't be cut / grep / sed'ed its not too useful and usually in the way!
l

loud-laptop-89838

01/06/2023, 4:17 PM
Fair. I lean towards pyproject.toml because it gives me one place to define other configs like linting tools, so I don't have half a dozen .configsomething. But your point is good
e

enough-analyst-54434

01/06/2023, 4:18 PM
Yeah, for those it tends to work since I have not found many needs for glue tooling. Black does its thing, no other tool cares, etc. Requirements are a different story though. ~Everybody cares about those.
If there were a jq for toml, that would also be a different story.
l

loud-laptop-89838

01/06/2023, 4:29 PM
Either way it gives me some good stuff to think about. Thanks!
p

polite-garden-50641

01/06/2023, 4:31 PM