New submission from STINNER Victor <vstin...@redhat.com>:
The PEP 587 adds new functions taking command line arguments: Py_PreInitializeFromArgs(config, argc, argv) Py_PreInitializeFromWideArgs(config, argc, argv) Py_InitializeFromArgs(config, argc, argv) Py_InitializeFromWideArgs(config, argc, argv) I propose to add _Py_RunMain() (currently private, until PEP 587 is accepted) to be able to implement something similar to Py_Main() but with way more configuration options: Example to create an "isolated Python" in a few line of C: --- #include <Python.h> int main(int argc, char *argv[]) { _PyCoreConfig config = _PyCoreConfig_INIT; config.isolated = 1; _PyInitError err = _Py_InitializeFromArgs(&config, argc, argv); if (_Py_INIT_FAILED(err)) { _Py_ExitInitError(err); } return _Py_RunMain(); } --- It's like the regular "python3" program, except that it's always isolated: --- $ my-isolated-python Python 3.8.0a3+ (heads/run_main-dirty:d167362ecc, Mar 29 2019, 13:03:30) >>> 1+1 2 >>> import sys >>> sys.flags.isolated 1 --- Using _Py_RunMain(), it becomes trivial to implement something like PEP 432's "system python" idea ;-) ---------- components: Interpreter Core messages: 339106 nosy: ncoghlan, vstinner priority: normal severity: normal status: open title: PEP 432, PEP 587: Add _Py_RunMain() versions: Python 3.8 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue36471> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com