pytest-plugins icon indicating copy to clipboard operation
pytest-plugins copied to clipboard

shutil run module using sys.executable

Open jayvdb opened this issue 6 years ago • 2 comments

I was surprised that the very common case of "run package module using sys.executable" isnt supported. i.e. [sys.executable, '-m', 'package']

It isnt the same as run_module_as_main, as invoking the real Python executable can be necessary to catch extra problems related to IO setup, esp LANG, PYTHONIOENCODING etc.

It is quite often done incorrectly, e.g. without quotes around sys.executable as I did above, which is usually ok on unix but often fails on Windows.

jayvdb avatar Oct 08 '19 07:10 jayvdb

Possibly/probably? want to use get_real_python_executable as part of this, and could also smartly only add the quotes when it is necessary, and leave them out when not beneficial.

jayvdb avatar Oct 08 '19 07:10 jayvdb

Good suggestion - thanks for this. Sorry for the ridiculously long time to reply!

eeaston avatar Nov 19 '21 16:11 eeaston