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

Donald Stufft donald at stufft.io
Sat Sep 5 18:38:29 CEST 2015

On September 5, 2015 at 11:40:17 AM, Steven D'Aprano (steve at pearwood.info) wrote:
> On Sat, Sep 05, 2015 at 04:08:24PM +0900, Stephen J. Turnbull wrote:
> > Steven D'Aprano writes:
> >
> > > You say "of course", but did you actually look at the python-list
> > > archives? If you do, you will see posts like these two within the last
> > > 24 hours:
> >
> > So let's fix it, already![1] Now that we have a blessed package
> > management module, why not have a builtin that handles the simple
> > cases? Say
> >
> > def installer(package, command='install'):
> > ...
> Python competes strongly with R in the scientific software area, and R
> supports a built-in to do just that:
> https://stat.ethz.ch/R-manual/R-devel/library/utils/html/install.packages.html 

I don't know anything about R, but a built in function is a bad idea. It'll be
a pretty big footgun I believe. For instance, if you already have requests 2.x
installed and imported, and then you run the builtin and install something
that triggers requests 1.x to be installed you'll end up with your Python in
an inconsistent state. You might even end up importing something from requests
and ending up with modules from two different versions of requests ending up
in sys.modules. In addition, the standard library is not really enough to
accurately install packages from PyPI. You need a real HTML parser that can
handle malformed input safely, an implementation of PEP 440 versions and
specifiers (currently implemented in the "packaging" library on PyPI), you also
need some mechanism for inspecting the currently installed set of packages, so
you need something like pkg_resources available to properly support that.

Donald Stufft
PGP: 0x6E3CBCE93372DCFA // 7C6B 7C5D 5E2B 6356 A926 F04F 6E3C BCE9 3372 DCFA

More information about the Python-ideas mailing list