Following the discussion on the first published version of PEP 771 in February, we are happy to share with you the updated version of PEP 771: Default Extras for Python Software Packages:
Let’s discuss this updated version here, and no longer use the previous thread. Thank you to everyone who participated in the previous discussion!
The main changes since the last published version based on feedback in the previous thread are as follows:
Standard/universal way of requesting a minimal installation
package[]
is now considered to be the primary way to specify that a package without any default extras is being requested (rather than letting each package define its own minimal extras such as package[minimal]
or package[nodefaults]
).
The main benefit of allowing this is that package[]
is already valid syntax and is currently a no-op, so package[]
will always mean ‘package
with no default extras’ including for packages predating default extras, and for installer tools predating default extras. Therefore, packages who only need a minimal installation of a dependency can safely use package[]
regardless of whether it applies to versions before/after the implementation of PEP 771, and will work even for users who have old versions of package installers.
In addition, standardizing this will mean that users will not need to depend on package maintainers implementing this option, and will not have to delve into the documentation for each separate package to figure out what the correct minimal extra is, if it exists.
The prototype implementation of PEP 771 in pip has been updated to support this, for anyone interested in trying it out.
Discussion of the alternative of splitting packages
The alternative approach of splitting packages into two, with a core package with minimal dependencies, and a meta-package that adds recommended dependencies, has now been added as a Rejected Idea in Using a meta package for recommended installations
To summarize our view on this approach: it is technically feasible, but it is a much higher burden for package developers, can lead to confusion for users, and would have the risk of breaking some user workflows for existing packages that want to transition. This is just a very rough summary, so please read the section in the PEP for more details.
Mention packages that have e.g. both backends and frontends
We have added text regarding packages that have e.g. both multiple backends and frontends and might want at least one default for each (and more generally, packages that might have different kinds of defaults). This can be found in the new section Packages with multiple kinds of defaults
Mention accepted PEP 751
PEP 751, which defines a new lockfile format, is now mentioned in Packaging-related tools as a solution to the pip freeze
issue mentioned in the same section, because the PEP 751 format explicitly lists packages to be installed without resolving dependencies.
If there is still a general consensus that the pip freeze
in its current form should not install default extras, and that recommending the usage of --no-deps
is not enough in those situations, then it is an option for pip freeze
to include []
after packages that use default extras, or even after all packages (but this is not part of the current PEP, and should perhaps not be in any case as it is a decision for the pip developers to make).
Added text on documenting default extras
We have added a new section, Documenting packages with default extras, layout out best practices for what package maintainers should document in relation to default extras.
Considering default extras as ‘weighty’ as required dependencies
We now mention that default extras should be added as carefully as required dependencies, and give pytest as an example of an ecosystem where default extras will effectively always be installed unless downstream packages were to adapt their dependencies. This new text is in Avoiding the addition of many default dependencies
Other changes
Other changes have been made following feedback in the previous discussion, including changing some of the example packages listed in Motivation, removing the open issue relating to package[]
since that is now implemented, and various spelling/grammatical issues.