Given the following pyproject.toml
file, how do I install the optional package ipdb
?
[tool.poetry]
name = "yolo"
version = "1.0.0"
description = ""
authors = []
[tool.poetry.dependencies]
python = "^3.8"
Django = "^4.0.4"
ipdb = {version = "^0.13.6", optional = true}
[tool.poetry.dev-dependencies]
pytest = "^5.4.1"
The Poetry Documentation shows how to add an optional package to the pyproject.toml
file, but not how to actually install it if I am given the file and have a blank environment.
Optional dependencies must be clusters within an extra
to be installable: https://python-poetry.org/docs/pyproject/#extras
So, your pyproject.toml
could look like this:
[tool.poetry]
name = "yolo"
version = "1.0.0"
description = ""
authors = []
[tool.poetry.dependencies]
python = "^3.8"
Django = "^4.0.4"
ipdb = {version = "^0.13.6", optional = true}
[tool.poetry.dev-dependencies]
pytest = "^5.4.1"
[tool.poetry.extras]
debug = ["ipdb"]
Than use poetry install -E debug
to install this extra.
At the moment the CLI is missing an option to add an optional dependencies to an extra
group.
Side note: extras
are meant for additional functions of your package during runtime. If you only need ipdb
during development, I would suggest to add it a as dev-dependencies
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.