Add ability to specify "default" extras_require
See original GitHub issueLibraries 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:
- Created 6 years ago
- Reactions:69
- Comments:32 (11 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
No, not a single package will break. Just to introduce a new syntax: you can define
None
in theextras_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 theinstall_requires
and theNone
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.
I like the idea of allowing
install_requires
to be replaced byextra: { None: [list, of, requirements] }
. This is howpkg_resources
used to work and it reduces the total number of concepts in the system, withinstall_requires
being a special case ofextra
. The idea of removing a special extra if any others have been chosen would be a new feature.