question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adding extras for dependencies

See original GitHub issue

Is there a way to specify extras that should be installed from a dependency? For example, I’d like to specify:

poetry add sqlalchemy[postgresql]

Since my project requires sqlalchemy and postgresql, but the only hard dependency is sqlalchemy, so depending on psycopg2 directly doesn’t make sense. psycopg2 being the package that is installed as a sqlalchemy extra when you ask for postgresql.

This way if sqlalchemy changes the postgresql extra to something else I’d automatically pick up the change.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:5
  • Comments:19 (8 by maintainers)

github_iconTop GitHub Comments

12reactions
carlosjgpcommented, Apr 1, 2022

it works if you add single quotes

poetry add 'package[extra1,extra2]'
6reactions
sdispatercommented, May 18, 2018

@bertjwregeer The extras feature works fine but in your case there is a problem which prevents poetry from getting sqlalchemy’s dependency information.

Here is the breakdown of what happens:

  • First, poetry checks the PyPI JSON API (https://pypi.org/pypi/SQLAlchemy/json)
  • Since it can’t get dependencies (requires_dist is null), it proceeds with downloading and inspecting the release tarball (https://files.pythonhosted.org/packages/c1/c8/392fcd2d01534bc871c65cb964e0b39d59feb777e51649e6eaf00f6377b5/SQLAlchemy-1.2.7.tar.gz).
  • First, it checks if it can get the dependency information from the PKGINFO file, which is not possible in this case.
  • Then, it checks if there is a *.egg-info directory which contains a requires.txt file containing the dependency information (this is a fairly common case). But in this case it does not exist.
  • At this point, poetry could execute the setup.py file but I don’t feel confortable doing that just for the sake of getting dependencies since to me it introduces a security risk and will sometimes fail due to C extensions or missing dependencies referenced in setup.py.
Read more comments on GitHub >

github_iconTop Results From Across the Web

What is 'extra' in pypi dependency? - Stack Overflow
Extras are dependencies you can install in addition to the regular dependencies, if you ask for them explicitly. See them as optional ...
Read more >
A Better Practice for Managing Many extras_require ...
In this article, I introduce a simple yet effective solution to manage optional dependencies via extras_require in Python. This method is ...
Read more >
Adding a default extra_require environment - Packaging
Possible default extras/dependency categories? Somehow related, I opened yesterday an issue on Github with a potential workaround which ...
Read more >
Installation — Anvil Extras documentation - Read the Docs
Install as a third-party dependency · From the gear icon at the top of your app's left hand sidebar, select 'Dependencies' · In...
Read more >
Commands | Documentation | Poetry - Python dependency ...
poetry install Installing dependencies from lock file No dependencies to ... want to install provide extras, you can specify them when adding the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found