:wave: hi all. i have what i think is a simple que...
# general
b
👋 hi all. i have what i think is a simple question but i’m not sure how to phrase my googles properly as I’m fairly new to pants. I have a monorepo with a number of different Lambda functions. I’m using poetry to setup a
src
package structure for each lambda. Each lambda will (eventually) have a dependency on a library that we are also developing - I have also used poetry to set up the
src
layout for this library. In my
pants.toml
file I have my source roots defined as:
Copy code
[source]
marker_filenames = ["pyproject.toml"]
I also went with a single lockfile for the repo because the number of third party dependencies across all of the Lambdas + shared library code is somewhat small (around 6 or so currently). My question is this - what’s the “standard practice” way to tell Pants that the Lambdas will have a shared dependency that’s in the same monorepo? ie - is this handled via BUILD file modification, or should I be doing something with
pyproject.toml
in the Lambda package directories (ie 1. specifying a local distribution, or 2. packaging the shared library up, sending it to our gitlab package registry, then listing this shared library as any other 3rd party dependency in pyproject.toml)
c
Pants should be able to automatically infer the dependency. for example, if you have a library lib0, in an app app0 you should just be able to write
import lib0
and Pants will pull in the lib0 source.
./pants dependencies
should show you if it's being picked up.
b
ah sorry that was meant to be my #3 - if it was as easy as just writing the import statements in the Lambda functions and Pants would do the rest
c
doing 2 is possible, but it's a bit weirder because the library is technically a different dependency world than the lambdas (since the lambdas depend on the shared lib but the shared lib doesn't depend on itself). So you could create 2 resolves (1 for the lib, 1 for the lambdas) and a python_distribution target for the lib. This can be useful for some compliance scenarios.
haha yeah, it should just be that easy!
b
excellent thanks for that feedback re option 2. I will do some experimentation - thanks for pointing me in the right direction!
all right i’m banging my head against the wall a bit here - should i not be adding dependencies via poetry? if i do something like
./pants dependencies ::
i’m getting warnings worded something like “we can’t safely infer which target this dependency is for” if some lambdas share 3p dependencies (which i have declared/added via poetry)