Search code examples
command-line-interfacepython-poetry

Add dependencies to [tool.poetry.extras]


I need to add dependencies to extra dependencies of my package, not packages that I depend on.
But everywhere it's described how to add package to my dependencies with their extras (e.g. documentation or this question)

My pyproject.toml contents:

[tool.poetry]
name = "my_project"

[tool.poetry.dependencies]
python = ">=3.8"
PyYAML = {version = "^6.0", optional = true}
matplotlib = {version = "^3.5.1", optional = true}

[tool.poetry.extras]
my_extras = ["PyYAML"]

Previously I just manually edited pyproject.toml, but now these bundles of extras are propagated to poetry.lock, so if I do it just in pyproject.toml I get warning from poetry that my lock file and pyproject file are not synchronised. (Of course I can edit them simultaneously, but it's a dirty way)

What is the command to add matplotlib to my_extras?


Solution

  • At the moment there is no command to add a dependency to an extra group. You have to manual edit the pyproject.toml and run poetry lock --no-update afterwards.