[issue31874] [feature] runpy.run_module should mimic script launch behavior for sys.path

Jason R. Coombs report at bugs.python.org
Sat Aug 11 13:39:18 EDT 2018


Jason R. Coombs <jaraco at jaraco.com> added the comment:

In [setuptools 1453](https://github.com/pypa/setuptools/issues/1453), this issue hit the project hard. Tox 3.2 changed the default invocation of pip from the script-based invocation to the runpy based implementation (python -m pip), which causes pip to be unable to uninstall the setuptools in the environment.

This use case also reveals that the heuristic of "retain '' in sys.path if the module being executed is in a subdirectory of a current directory" wouldn't address the issue, as `.tox/python/lib/python3.7/site-packages/pip/__main__.py` is in a subdirectory of the current directory, but one would still expect '' not to be in sys.path in this case.

But basing on __main__.__spec__, that would probably do what is expected.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31874>
_______________________________________


More information about the Python-bugs-list mailing list