Is it valid to specify extra "negative" dependency with PEP508 markers?

I believe that for dependency resolvers, extra dependencies are directly referred from extra marker in the dependencies within package metadata. However, most of the usages are only for specifying extra additional dependencies, thus having extra == foo form. I wonder whether we can exploit full PEP508 syntax to specify negative dependencies by extra != foo form, so that when the extra is present, we don’t install the dependency?

Requires-Dist: very-large-dependency ; extra != "min"
Requires-Dist: clikit ; extra == "cli"

I confirmed it works for the latest (20.2.3) pip, but I’m concerned that there are other internals that assumes extras are only with the “==” operator. (For example, neither poetry nor pipenv recognized the extra negative dependency syntax; pipenv installed everything as if there is no extras, and poetry installed nothing as if extra condition is not met.) I want to know whether this is reliable feature that we can count on.

1 Like

There was a recent discussion about this. It didn’t reach a conclusion, but may be helpful. The 'extra' environment marker and its operators

2 Likes