[Python-ideas] High time for a builtin function to manage packages (simply)?

Andrew Barnert abarnert at yahoo.com
Mon Sep 7 07:12:08 CEST 2015


On Sep 6, 2015, at 20:25, Chris Angelico <rosuav at gmail.com> wrote:
> 
> On Mon, Sep 7, 2015 at 1:17 PM, Andrew Barnert via Python-ideas
> <python-ideas at python.org> wrote:
>> Anyway, the problem comes when you upgrade (directly or indirectly) a module that's already imported. Reloading is neither easy (especially if you need to reload a module that you only imported indirectly and upgraded indirectly) nor fool-proof. When I run into problems, I usually don't have much trouble stashing any costly intermediate objects, exiting the REPL, re-launching, and restoring, but I don't think novices would have as much fun.
>> 
>> Is there a way the installer could, after working out the requirements, tell you something like "This command will upgrade 'spam' from 1.3.2 to 1.4.1, and you have imported 'spam' and 'spam.eggs' from the package, so you may need to restart after the upgrade. Continue?" That might be good enough. It's not exactly an everyday problem, so as long as it's visible when it's happened and obvious how to work around it so users who run into it for the first time don't just decide Python or pip or spam is "broken" and give up, that might be sufficient.
> 
> How often does pip actually need to upgrade an already-installed
> package in order to install something you've just requested?

Not that often, which is why I said "It's not exactly an everyday problem"; just often enough that some novices are going to run into it once or twice, so it can't be ignored.

> Maybe the
> rule could be simpler: if there are any upgrades at all, regardless of
> whether you've imported from those packages, recommend a restart.

I suppose that's possible too. It's overzealous, but it still won't happen _that_ often, so if my suggestion is too much work, this one seems fine to me.

Especially if the message made the issue clear, something about "After an upgrade, you should restart, because any packages you already imported may be unchanged or inconsistent".

> The
> use-case I'd be most expecting is this:
> 
>>>> import spam
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
> ImportError: No module named 'spam'
>>>> install("spam")
> ... chuggity chug chug ...
>>>> import spam
> 
> In the uncommon case where spam depends on ham v1.4.7 or newer *AND*
> you already have ham <1.4.7 installed, a simple message should
> suffice. (Oh, and you also have to not have any version of spam
> installed already, else you won't be able to use install() anyway.)
> 
> ChrisA
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/


More information about the Python-ideas mailing list