[issue42260] [C API] Add PyInterpreterState_SetConfig(): reconfigure an interpreter
Chris Meyer
report at bugs.python.org
Wed Nov 11 12:46:43 EST 2020
Chris Meyer <cmeyer1969 at gmail.com> added the comment:
> How do you configure sys.path currently? Do you parse a configuration file? Do you use a registry key on Windows?
We have several launch scenarios - but for the currently most common one, which is to launch using a separate, existing Python environment, we call Py_SetPythonHome and Py_SetPath with the home directory of the environment. Then, presumably, the more complete path gets set in either Py_Initialize or when we call PyImport_ImportModule(“sys”). I might have tracked the details down once, but I don't recall them. By the time our Python code starts running, sys.path is reasonably populated.
However, in another scenario, we launch with an embedded Python environment, essentially a virtual environment. In that case, we have a config file to explicitly add lib, DLLs, and site packages. But something goes wrong [cannot find/load the unicode DLL IIRC] unless we call site.addsitedir for each directory already in sys.path near the start of our Python portion of code. My notes point to two issues to explain this: https://bugs.python.org/issue22213 and https://bugs.python.org/issue35706.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42260>
_______________________________________
More information about the Python-bugs-list
mailing list