This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA] ignore PYTHONHOME environment variable.
> <jan.kratochvil@redhat.com> wrote:
> > But PYTHONHOME=$HOME for some user overrides of system Python would
> > no longer work. ?What would $PYTHONHOME otherwise be useful for?
>
> OTOH what if one wanted to debug a python with a different PYTHONHOME?
> GDB_PYTHONHOME? [not my idea, but seems reasonable]
I think you indeed need something like that. I don't think we can trust
PYTHONHOME, because it might point to something that's incompatible.
GDB_PYTHONHOME is something that got suggested by at least 2 people
(someone at AdaCore also suggested it a while back). I have to wonder,
though, why you would want to run GDB with a different version of Python
than then one used to build GDB with. If you want to use your own
scripts, you can use the PYTHONPATH.
Still, we can add that too, something like that:
#ifdef WITH_PYTHON_PATH
if "GDB_PYTHONHOME" is defined
Py_SetPythonHome (getenv ("GDB_PYTHONHOME"));
else
/* We override any value that the PYTHONHOME might have, as we want
to make sure that we use the Python library that comes with GDB. */
Py_SetPythonHome (ldirname (python_libdir));
#endif
But I think I would prefer something like this:
if "GDB_PYTHONHOME" is defined
Py_SetPythonHome (getenv ("GDB_PYTHONHOME"));
#ifdef WITH_PYTHON_PATH
else
/* We override any value that the PYTHONHOME might have, as we want
to make sure that we use the Python library that comes with GDB. */
Py_SetPythonHome (ldirname (python_libdir));
#endif
The latter makes GDB_PYTHONHOME always active, regardless of how
GDB was linked against Python.
--
Joel