[Python-ideas] High time for a builtin function to manage packages (simply)?
abarnert at yahoo.com
Mon Sep 7 05:17:53 CEST 2015
On Sep 6, 2015, at 19:18, Steven D'Aprano <steve at pearwood.info> wrote:
> I didn't specify whether the interactive interface should be a
> stand-alone application like pip, or an command in the REPL like R uses,
> or even both. I like the idea of being able to install packages directly
> from the Python prompt. It works well within R, and I don't see why it
> wouldn't work in Python either. But it isn't much of an imposition to
> run "python -m pip ..." at the shell.
Personally, I've never found ^Zpython -m pip spam && fg too hard (or just using ! from IPython), but I can understand why novices might. :)
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.
(And a GUI installer integrated into IDLE would presumably have no additional problems, and could make the experience even nicer--especially since it's already got a "Restart Shell" option built in.)
More information about the Python-ideas