Monorepo setup using Poetry for different classes of projects #19658
Replies: 6 comments 10 replies
-
(Separate comments for easier threading/replies)
This suggests that the "source roots" aren't configured appropriately, so pants isn't aware that |
Beta Was this translation helpful? Give feedback.
-
(Separate comments for easier threading/replies)
We do something similar: use poetry to actually manage adding/removing our dependencies, but pants to run our code, and it works fine. We have a test that runs in CI for checking our pants lock file is up to date with our poetry one, so that we can't forget |
Beta Was this translation helpful? Give feedback.
-
(Separate comments for easier threading/replies)
Potentially... you may need to package these up as |
Beta Was this translation helpful? Give feedback.
-
Sharing the working code in case anyone is interested in a similar approach: https://github.com/zbitouzakaria/python-monorepo-pants-poetry, I've had a lot of fun trying to set this up and I'm already blown away by the capabilities of Pants 👏🏻😄 |
Beta Was this translation helpful? Give feedback.
-
Actually, one last question 😛 To completely ignore the projects under
Any idea how to do this properly ? |
Beta Was this translation helpful? Give feedback.
-
I'm curious - what are you using Poetry for in this repo? What does it provide in addition to Pants? |
Beta Was this translation helpful? Give feedback.
-
Hi everyone!
I'm working on setting up a monorepo using Pants and Poetry to manage multiple classes of Python projects, and I would love to gather your feedback on the choices made. We have specific requirements to factor in:
Requirements and Intent
We have two main classes of projects:
release
projects: These are the ones that have deployed artifacts running on our cloud. We want to ease the development of new services by having them neatly organized in a single repo, allowing easy composition of libs for shared usage. We can use visibility rules to ensure a service cannot depend on another service and these can be subdivided in multiple "universes" of dependencies, through resolves. ClassicPants
use case.sandbox
projects: These are of the exploratory kind (e.g some data science projects). We want them isolated since they might use packages with unstable APIs, or just fill a quick need for insights. We don't put them in a separate repo because we believe we can ease the bootstrap of such projects as they might need specific cloud infrastructure, and they could benefit from using libs from ourrelease-*
resolves. Usefulness will be limited if they have to comply to our whole universe of dependencies, so they need to be able to pick up just a lib and it's direct dependencies.I started from poetry#6850 and worked from there.
Monorepo Structure
The file
py/projects/resolve-core/pyproject.toml
uses path dependencies references to the relevant projects, and each project describes it's own set of dependencies. This way they can be worked on either in isolation usingpoetry
or usingpants
goals (the CI ensurespants generate-lockfiles ::
doesn't break)I've tried to implement this (need to do some refactoring then I can share a working repo) and wanted to share a few insights (also had a few questions):
pants tailor ::
I didn't have to modify any of the generatedBUILD
files to make this work (yet).python
version requirements was declared under the group[tool.poetry.group.main.dependencies]
, whichpoetry
seems to support.pants
didn't though and understoodpython
as a third-party dependency e.g.pants dependecies /path/to/file
fails to detect the dependency when trying to import a relative module using the absolute syntax, have any idea why ? e.g:resolve-pytorch
can use libs fromresolve-core
, would it make sense to put those libs elsewhere ?poetry add
and leverage it's dependency resolution process. We'll still need topants generate-lockfiles ::
to integrate it into our resolve. But the cool thing is that we can work either with a poetry virtualenv or directly with Pants goals.sandbox
project can add a relative path dependency to a lib and get going with poetry, which is nice.I'm looking for feedback on potential issues with this build setup, any insight or suggestion would be highly appreciated.
Thank you for taking the time to review this!
Beta Was this translation helpful? Give feedback.
All reactions