danodonovan
danodonovan

Reputation: 20373

Use pip to install poetry group dependencies from VCS

I have a project on VCS / GitHub that is managed using poetry. In that project I use poetry dependency groups. For example

[tool.poetry.dependencies]  # main dependency group
httpx = "*"
pendulum = "*"

[tool.poetry.group.server.dependencies]
streamlit = "^1.13.0"

Is it possible to pip install the GitHub project and the dependencies?

$ pip install git+ssh://[email protected]/my/project.git@main#egg=project

(for example) will install httpx and pendulum, but not streamlit.

We could move the dependencies from the group into [tool.poetry.dependencies] but this defeats the purpose of the poetry group dependencies.

Upvotes: 0

Views: 573

Answers (1)

danodonovan
danodonovan

Reputation: 20373

From reading more, I believe I'm using poetry group dependencies incorrectly (group dependencies should be used during development). What I should be doing is to use extras - as in

[tool.poetry.dependencies]  # main dependency group
httpx = "*"
pendulum = "*"
streamlit = { version = "^1.13.0", optional = true }

[tool.poetry.extras]
server = ["streamlit"]

Then we can install the extras with

$ pip install git+ssh://[email protected]/my/project.git@main#egg=project[server]

Upvotes: 1

Related Questions