I am building a Python package using pyproject
and poetry
. My pyproject.toml
looks like this:
[tool.poetry]
authors = ["test"]
description = ""
name = "test"
version = "0.1.0"
[tool.poetry.dependencies]
spacy = {extras = ["cuda113"], version = "^3.2.3"}
faiss-gpu = {version = "1.7.2", optional = true}
[tool.poetry.extras]
gpu = ["faiss-gpu"]
This successfully installs faiss-gpu
as an extra using poetry install -E gpu
.
However, I would like to install spacy[cuda113]
(GPU version) only when poetry install -E gpu
is provided. A normal poetry install
should only install spacy
(CPU version).
I've tried using the following configuration, but this makes all of spacy
optional and doesn't install it. Only spacy[cuda113]
(GPU version) must be optional.
[tool.poetry]
authors = ["test"]
description = ""
name = "test"
version = "0.1.0"
[tool.poetry.dependencies]
spacy = {extras = ["cuda113"], version = "^3.2.3", optional = true}
faiss-gpu = {version = "1.7.2", optional = true}
[tool.poetry.extras]
gpu = ["faiss-gpu", "spacy"]
Is there a way to make spacy[cuda113]
optional but spacy
as a required dependency?
A normal poetry install should only install spacy (CPU version).
So I want the base spacy library to not be an extra and always be installed. – Dyke