Hey. We have a monorepo with few python packages c...
# general
l
Hey. We have a monorepo with few python packages containg their own
pyproject.toml
. Is it recommended to spec the requirements in each project like we do now or just combine all requirements in one big requirements.txt and let pants figure everything else out?
r
Generally it's recommended to combine them all unless you have to support things like different python versions for different packages etc. It will definitely make your life easier.
Once you combine them, it's strongly recommended to use lockfile, if you don't do it already.
l
Makes sense. A question related to dependencies. Do all the dependencies we directly import need to be added to requirements.txt? I am seeing errors for things that are transitively installed but we import directly
r
yeah whatever you import directly need to be specified. Pants will pull the underlying transitive dependencies of these packages but you are not supposed to rely on that fact
l
Obviously makes sense, it was just enexpected and errors not that friendly 🙂
r
what does it say? It should actually warn you that it couldn't infer import etc from your provided list of dependencies. Which pants version are you on?
l
I am just runnings pants test and getting
ModuleNotFoundError
from tests themself
pants_version = "2.16.0rc6"
r
That
ModuleNotFoundError
might be something else.
Or could be because of missing dependencies. Not sure. Try with first specifying all import
l
yup
will do
is there something else i should be running before tests? to get some pants feedback if anything is missing?
r
I don't think so. The only think I can think of is to generate a lockfile first after you have mentioned all dependencies.
l
yeah just doing that. Atleast its faster than poetry which takes 30min+ for us 🤦
r
Oh wow! Really? Pants can have issues when you specify python ranges using
interpreter_constraints
which are too wide like ">=3.9, <3.12"
h
Dep inference should warn or error (depending on your settings) if you import code that it can't map back to a providing module
So if you don't get a warning and pants proceeds to run tests and then fails at test time, then it's possible the dep can't be inferred for some reason
A specific example would be helpful!