[Distutils] Metadata 2.0: Warning if optional features are missing

Michael Merickel mmericke at gmail.com
Tue Dec 15 11:37:32 EST 2015

On Tue, Dec 15, 2015 at 9:20 AM, Paul Moore <p.f.moore at gmail.com> wrote:

> This is more a thought for something that would be good to include in
> Metadata 2.0, or whatever ends up taking its place.
> I was installing some packages on a new PC, that doesn't have a
> compiler. As I did so, I noticed a dependency on sqlalchemy fly by,
> and I thought "oh, that's going to fail", as it's always needed a
> compiler. But it didn't. I presume sqlalchemy has an optional
> dependency on something like a speedup module.
> What would be good is a way for packages to declare that they provide
> optional features like this, and for pip (and user code) to be able to
> introspect that data. The n"extras" feature in Metadata 2.0 is sort of
> like that, but in an "on request" form (I can install foo[speedups]
> and that has additional requirements, but the install will fail if
> they are not present).

It seems to me this would be easily accomplished by declaring some extras
like "cext" as default-included and if the install fails someone can depend
on "sqlalchemy[-cext]". The UI isn't quite as nice as your proposal but
reuses existing machinery.

> What I'd like to be able to do:
> 1. pip install sqlalchemy works, but shows a warning "optional feature
> speedups not installed - no C compiler"

Extras wouldn't give a nice message like this. The install would fail and
the user would have to guess as to why and then opt out of the default
extra. Perhaps some better error message could be displayed if the package
failed to install and had a default extra included to show how to opt out.

> 2. A command to list any installed packages with optional features
> that aren't installed:
>    $ pip options -l
>    sqlalchemy speedups [C compiler]

It'd be nice to have a command to list the extras, I'm unaware of one right

> 3. A command to reinstall the currently installed version with new options
>    pip install --add-options sqlalchemy[speedups]
>    (Note that a plain pip install doesn't do this, as it won't
> reinstall. And --upgrade or --ignore-installed will install newer
> versions).

This should be done by simply reinstalling the package via "pip install
sqlalchemy[speedups]". I doubt you need an extra --add-options flag to
compete with extras.

- Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/distutils-sig/attachments/20151215/3a721877/attachment-0001.html>

More information about the Distutils-SIG mailing list