[Distutils] Module Installation Issues

Steve Dower steve.dower at python.org
Tue Sep 13 18:41:45 EDT 2016

On 13Sep2016 1500, Paul Moore wrote:
> On 13 September 2016 at 21:12, Thomas Kluyver <thomas at kluyver.me.uk> wrote:
>> One thing I'd quite like to see Python grow is a standard function to
>> install packages from inside Python.
> That's not too hard in principle - pip.main(['install', package]) is
> basically all you'd need (modulo various design details, and wrapping
> it in a nice user friendly function). The bigger problems are:
> 1. pip is an independent module (albeit shipped with Python) and it's
> not clear to what extent Python would want a builtin function that
> depends on a non-stdlib module. But that's not a technical issue.
> 2. Python's module system isn't really designed around installing new
> modules while a process is running. There's caching involved, so the
> effects can be unpredictable. It's difficult to know whether the
> benefits (avoiding confused users who tried to install from a Python
> prompt) would outweigh the costs (confused users having installed a
> module but not being able to see it because the module system didn't
> notice things had changed).
> I'm not honestly sure how big the "installing while a process is
> running" issue would be - I did a few simple experiments and couldn't
> immediately trigger weirdness, but I believe it can happen. And things
> get significantly worse if we allow upgrades from the Python prompt
> rather than just installs (e.g., if you have already imported
> something from the old version and then upgrade).
> Overall, it'd probably be a nice thing to have, but it's nowhere near
> as simple as it seems at first glance.
> Paul

I think it's one of these things where we should suck it up and let the 
90% case work fine, then display a big fat warning if anything weird may 
have happened and let users sort it out themselves.

A simple builtin that tries to run "sys.executable -m pip {args}" in a 
subprocess and displays "success", "success but you should probably 
restart Python now", "failed because you don't have pip", "failed and 
have all the output" is going to make lots of people happy, even if it 
upsets those who want it to be perfect in every scenario.


More information about the Distutils-SIG mailing list