Related: Pip wheel install doesn't handle extra marker. · Issue #8469 · pypa/pip · GitHub
Currently it is possible to supply the following in METADATA
:
Name: a
Version: 1.0
Provides-Extra: new-b
Requires-Dist: b >= 2; extra == 'new-b'
Requires-Dist: b < 2; extra != 'new-b'
While this logically makes sense, it seems to go against the original intention of the extras feature, i.e. to add optional dependencies to a package. And indeed, none of the current installer implementations handle this correctly. I also could not find similar things in other packaging ecosystems—all equivalents to Python package extras only allow a package to include more specifications, not remove from the base requirements.
My proposal is to amend PEP 508 to explicitly special-case extra
, and disallow all operators other than ==
. This would free up installers from dealing with convoluted edge cases that rarely anyone really ever thought through, and likely make the specification fit better with how extra is originally designed.
The only relevent description in PEP 508 is
Comparisons in marker expressions are typed by the comparison operator. The
<marker_op>
operators that are not in<version_cmp>
perform the same as they do for strings in Python.
I don’t even want to think about what extra >=
should mean
PEP 426 described extras in more detail (saying they’re for “optional dependencies”). But that PEP was withdrawn, and did not clarify what optional dependencies mean either.