24

There are multiple projects in my monorepo, which has package management via Poetry individually. For instance,

monorepo
├── a
│   └── pyproject.toml
├── b
│   └── pyproject.toml
└── c
    └── pyproject.toml

Each project has its own sessions for [tool.poetry.dependencies] and [tool.poetry.dev-dependencies]. However, they did share huge amount of common configs such as

  • [tool.taskipy.tasks]
  • [tool.isort]
  • [tool.black]
  • ...

My question is how to define common configs which could be reused for monorepo projects?

2 Answers 2

1

See this discussion _https://github.com/python-poetry/poetry/issues/2270

You can do that by creating a local config (poetry.toml) for each of your sub-packages with virtualenvs.create false. You then mark the sub-packages as dependencies as suggested by @fredrikaverpil and include them as packages.

1
  • 1
    Will the main pyproject.toml pull the dependencies of the sub-projects in its main virtual env on poetry install? Commented Oct 21, 2022 at 12:01
1

You could go with

[tool.poetry.dependencies]
rootproject = {path = "path/to/root/project"}

However keep in mind that each dependency will still have its' own Virtual Environment, if that's not sufficient you can go with a different tool such as pip-tools.

1
  • Do you have a link to the documentation? Not entirely sure how to set this up. Commented May 7 at 18:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.