Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I specify "extra" / bracket dependencies in a pyproject.toml?

I'm working on a project that specifies its dependencies using Poetry and a pyproject.toml file to manage dependencies. The documentation for one of the libraries I need suggests pip-installing with an "extra" option to one of the dependencies, like this:

pip install google-cloud-bigquery[opentelemetry]

How should I reflect this requirement in the pyproject.toml file? Currently, there are a few lines like this:

[tool.poetry.dependencies]
python = "3.7.10"
apache-beam = "2.31.0"
dynaconf = "3.1.4"
google-cloud-bigquery = "2.20.0"

Changing the last line to

google-cloud-bigquery[opentelemetry] = ">=2.20.0"

yields

Invalid TOML file /home/jupyter/vertex-monitoring/pyproject.toml: Unexpected character: 'o' at line 17 col 22

Other variants that don't seem to be parsed properly:

google-cloud-bigquery["opentelemetry"] = "2.20.0"

There are other StackOverflow questions which look related, as well as several different PEP docs, but my searches are complicated because I'm not sure whether these are "options" or "extras" or something else.

like image 707
Sarah Messer Avatar asked Aug 31 '25 03:08

Sarah Messer


1 Answers

You can add it by poetry add "google-cloud-bigquery[opentelemetry]". This will result in:

[tool.poetry.dependencies]
...
google-cloud-bigquery = {extras = ["opentelemetry"], version = "^2.34.2"}
like image 71
finswimmer Avatar answered Sep 02 '25 15:09

finswimmer