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

Stephen J. Turnbull stephen at xemacs.org
Sat Sep 5 09:08:24 CEST 2015


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'):
        ...

where command would also take values 'status' (in which case package
could be None, meaning list all installed packages, and 'status' might
check for available upgrades as well as stating whether the package is
known to this python instance), 'upgrade', 'install' (which might
error if the package is already installed, since I envision
installations taking place in the user's space which won't work for
upgrading stdlib packages in a system Python, at least on Windows),
and maybe 'remove'.

I'm not real happy with the name "installer", but I chose it to imply
that there is a command argument, and that it can do more than just
install new packages.

In general, I would say installer() should fail-safe (to the point of
fail-annoying<wink/>), and point to the pip (and maybe venv) docs.
It should also be verbose (eg, explaining that it only knows how to
install for the current user and things like that).


Footnotes: 
[1]  This really is not relevant to the "localized turtle" thread.  If
the current situation is acceptable in general, it's not an argument
for putting turtle localizations in the stdlib.  If it's not
acceptable, well, let's fix it.



More information about the Python-ideas mailing list