poetry install multiple projects in the same environment
Asked Answered
D

1

8

I'm trying to solve what I assume is a common problem with poetry but am unable to find the relevant documentation. My project includes multiple packages and uses pyproject.toml and poetry to manage dependencies with this structure

/pyproject.toml
/poetry.lock

/package1/pyproject.toml
/package1/poetry.lock
/package1/src/package1/...

/package1/pyproject.toml includes pypi dependencies in [tool.poetry.dependencies] and defines the buildable package as

packages = [
    { include = "package1", from = "./src" },
]

/pyproject.toml references package1 with

[tool.poetry.dependencies]
package1 = { path = "./package1", develop = true }

Finally, my Dockerfile installs the application with

WORKDIR /app/package1
RUN poetry install
WORKDIR /app
RUN poetry install

The problem is that Poetry installs each "project" (identified by the pyproject.toml file) in a separate virtual environment, and doesn't seem to support installing both in the same environment. When I execute the application it can find package1 but none of package1's dependencies.

How can I get everything installed in the same environment?

How am I supposed to handle this situation?

Deckhand answered 25/9, 2022 at 23:24 Comment(0)
B
-4

you will need to package each project. Using poetry build. This will give you a .whl file that you could submit to a package repository like PyPi or Gitlab Package Repository, e.g. using the python package twine. You will need to mention the source for the packages in your pyproject.toml if it is not PyPi. How to tell poetry to grab the .whl packages from a local source I do not know. But eventuall you have one poetry project and then install all other projects as packages (using the .whl files you have created).

Blitz answered 11/8, 2023 at 13:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.