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 |
|
(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 |
|
(Separate comments for easier threading/replies)
Potentially... you may need to package these up as |
|
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 👏🏻😄 |
|
Actually, one last question 😛 To completely ignore the projects under Any idea how to do this properly ? |
|
I'm curious - what are you using Poetry for in this repo? What does it provide in addition to Pants? |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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:
releaseprojects: 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. ClassicPantsuse case.sandboxprojects: 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.tomluses 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 usingpoetryor usingpantsgoals (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 generatedBUILDfiles to make this work (yet).pythonversion requirements was declared under the group[tool.poetry.group.main.dependencies], whichpoetryseems to support.pantsdidn't though and understoodpythonas a third-party dependency e.g.pants dependecies /path/to/filefails to detect the dependency when trying to import a relative module using the absolute syntax, have any idea why ? e.g:resolve-pytorchcan use libs fromresolve-core, would it make sense to put those libs elsewhere ?poetry addand 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.sandboxproject 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!
All reactions