[Distutils] Module Installation Issues

Donald Stufft donald at stufft.io
Tue Sep 13 18:55:49 EDT 2016

> On Sep 13, 2016, at 6:41 PM, Steve Dower <steve.dower at python.org> wrote:
> 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.

I am unsure. One of the really egregious and hard to debug weirdness is going to be something like:

>>> import foo.bar  # foo, and foo.bar are in sys.modules
>>> pip.install(“thing”)  # This implicitly upgrades foo
>>> import foo.widget  # the old foo is in sys.modules, but the new foo.widget.

The 90% case works when it’s *only* pure python and there’s no upgrading/downgrading involved, however you can’t control whether there are going to be upgrades/downgrades or not when dependencies are in play because of ==, >=, >, <, <=, etc.

Another problem, particularly on Windows, is going to be stuff like:

>>> import someclibrary
>>> pip.install(“thing”)  # Implicitly upgrades someclibrary

In this case, this would explode because Python will have the someclibrary.dll locked and the upgrade will attempt to remove it.

My fears here are that people are going to get really confused when they make state modifications to their Python environment and they don’t see those modifications reflected (because of sys.modules caching or what have you). You can possibly get around that with reload(), but we already know the problems that reload() has. Of course, that doesn’t stop Python from offering reload(), but I think the difference is that reload() is targeted towards people with weird edge cases who can understand the caveats while the hypothetical ``pip.install()`` is targeted towards people who are beginners who are still having problems figuring out the difference between the REPL and their shell, much less the vagaries of Python’s global state and attempting to modify that in a now running Python program.

Perhaps a better idea would be to add some smarts to the REPL (but not to Python itself) that would detect something like:

>>> pip install

And print a better error message that gives a better indication about what’s gone wrong besides a SyntaxError?

Donald Stufft

More information about the Distutils-SIG mailing list