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.

Add ability to specify "default" extras_require

See original GitHub issue

Libraries that implement a client to an HTTP backend often provide multiple implementations such as for tornado, aiohttp or requests. Each implementation comes with its own dependencies. User usually needs only one implementation.

With extras_require developer of the library can specify aiohttp and torndao as optional and install requests for everyone via install_requires.

However, users of aiohttp and tornado do not need requests, hence the request to be able to specify a “default” extra that should be picked when no other extras are specified.

So that users calling pip install mylib or pip install mylib[requests] will get requests installed, but users calling pip install mylib[aiohttp] won’t.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:69
  • Comments:32 (11 by maintainers)

github_iconTop GitHub Comments

8reactions
jonas-eschlecommented, May 3, 2021

No, not a single package will break. Just to introduce a new syntax: you can define None in the extras_require as a key which defines requirements that are only additional to the default. Nothing will break since None is currently not allowed as a key, so no one has it. So the default is equal to an “extra” None.

if you install any extra, it takes the install_requires and the extra. If no extra is specified, it takes the install_requires and the None extra (trivially: which is empty in case it is not specified).

This makes the default less of a special case, in fact it makes everything more consistent.

7reactions
dholthcommented, Mar 31, 2021

I like the idea of allowing install_requires to be replaced by extra: { None: [list, of, requirements] }. This is how pkg_resources used to work and it reduces the total number of concepts in the system, with install_requires being a special case of extra. The idea of removing a special extra if any others have been chosen would be a new feature.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Adding a default extra_require environment - Packaging
We just need to allow users to create an environment called None. For now the following will fail: from setuptools import setup extras_require...
Read more >
Specify extras_require with pip install -e - Stack Overflow
This should work, per example #6. For remote repos: pip install -e git+https://github.com/user/project.git#egg=project[extra].
Read more >
Dependencies Management in Setuptools
Setuptools allows you to declare dependencies that are not installed by default. This effectively means that you can create a “variant” of your...
Read more >
A Better Practice for Managing Many extras_require ...
One problem I was facing when building GNES: Generic Neural Elastic Search is how to effectively control the dependencies in Python.
Read more >
Lessons learned from writing my first python package
extras_require shows its full power when combined with tox. You only need to specify the key (e.g. "dev") of the extra you want...
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