Skip to content
Advertisement

How to list the name of all Poetry extras?

I’m working on a project where I need to install all of the Poetry extras to run an automated build. What is the easiest way to get that list as a space-separated list, for use in poetry install --extras="$extras"?

Some possibilities:

  • I could use the Python toml package, but that would require setting up a separate virtualenv to install it.
  • A quick sed command to get the tool.poetry.extras section of pyproject.toml and pull out the names would be a hack, and only works if the TOML is nicely and consistently formatted.
  • Downloading and installing a third party CLI tool just for this seems overkill; I’d prefer a sed hack over that.
  • Maybe there’s a commonly installed tool (as in, already installed in the official Ubuntu 20.04 Docker image) which can do this or something adjacent like converting TOML to JSON for processing with a more well-known tool like jq, but I’m not aware of it.

Advertisement

Answer

Sorry, cannot add as a comment, but probably you could use now

poetry install --all-extras

with newer Poetry version https://python-poetry.org/docs/pyproject/#extras

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement