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

Chris Angelico rosuav at gmail.com
Mon Sep 7 05:25:32 CEST 2015


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? 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. 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


More information about the Python-ideas mailing list