Is Provides-Extra necessary for 'doc' and 'test' extras?

I’m attempting to build a package with some test and doc dependencies. According to the spec:

The specified name may be used to make a dependency conditional on whether the optional feature has been requested.

Two feature names test and doc are reserved to mark dependencies that are needed for running automated tests and generating documentation, respectively.

It is legal to specify Provides-Extra: without referencing it in any Requires-Dist:.

So it’s possible to provide Provides-Extra without any Requires-Dist, but it feels redundant to be supplying Provides-Extra when there exists a reference to the name. For example:

Requires-Dist: pytest; extra == "test"

It seems to me that should be a valid declaration. However, if one tries to pip install a package with that metadata using the extra (i.e. pip install .[test]), pytest will not be installed and pip will warn that the package provides no “test” extra.

Perhaps instead, installers should always install dependencies for indicated extras even if the package doesn’t explicitly (and redundantly) declare that it provides that extra.

Said another way, is there any point in declaring Provides-Extra other than to signal that some dependencies might be associated with that extra?

The obvious answer is to allow installers to catch typos - if you accidentally type pip install .[tset] you get an error rather than pip silently installing the package with no extras.

I imagine one possibility would be for the build backend to automatically compute Provides-Extra based on the extras used in the markers in the dependencies. Although I guess none of them currently do that.


As of yesterday, the backend does infer Provides-Extra from extras declared in dependencies. It’s not pretty, as there’s no routine for extracting extra markers from requirements (in packaging), but it does work in the typical case.