* [RFC] Help python find its files
@ 2010-02-08 19:30 Doug Evans
2010-02-08 19:56 ` Daniel Jacobowitz
2010-02-08 21:07 ` Tom Tromey
0 siblings, 2 replies; 5+ messages in thread
From: Doug Evans @ 2010-02-08 19:30 UTC (permalink / raw)
To: gdb-patches
Hi.
We had problems with python not being able to find its files.
This may be specific to installations where gdb and python
are installed in different places.
2010-02-08 Doug Evans <dje@google.com>
* configure.ac (--with-python): Define WITH_PYTHON_PATH if
--with-python arg is a path.
* config.in: Regenerated.
* configure: Regenerated.
* python/python.c (_initialize_python): If configured
--with-python=/path, pass a fake argv[0] to Py_SetProgramName so
python can find its files.
Index: configure.ac
===================================================================
RCS file: /cvs/src/src/gdb/configure.ac,v
retrieving revision 1.114
diff -u -p -r1.114 configure.ac
--- configure.ac 25 Jan 2010 13:22:02 -0000 1.114
+++ configure.ac 8 Feb 2010 19:08:11 -0000
@@ -652,6 +657,13 @@ else
AC_DEFINE(HAVE_LIBPYTHON2_4, 1, [Define if Python 2.4 is being used.])
fi
fi
+ if test ${have_libpython} = yes; then
+ case "${with_python}" in
+ /*)
+ AC_DEFINE_UNQUOTED(WITH_PYTHON_PATH, "${with_python}", [Define if --with-python contains a path.])
+ ;;
+ esac
+ fi
if test ${have_libpython} = no; then
case "${with_python}" in
yes)
Index: python/python.c
===================================================================
RCS file: /cvs/src/src/gdb/python/python.c,v
retrieving revision 1.25
diff -u -p -r1.25 python.c
--- python/python.c 18 Jan 2010 10:50:44 -0000 1.25
+++ python/python.c 8 Feb 2010 19:08:11 -0000
@@ -631,6 +631,12 @@ Enables or disables auto-loading of Pyth
&show_python_list);
#ifdef HAVE_PYTHON
+#ifdef WITH_PYTHON_PATH
+ /* Work around problem where python gets confused about where it is,
+ and then can't find its libraries, etc.
+ Lie and pretend argv[0] is in WITH_PYTHON_PATH. */
+ Py_SetProgramName(WITH_PYTHON_PATH "/bin/python");
+#endif
Py_Initialize ();
PyEval_InitThreads ();
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [RFC] Help python find its files
2010-02-08 19:30 [RFC] Help python find its files Doug Evans
@ 2010-02-08 19:56 ` Daniel Jacobowitz
2010-02-08 20:05 ` Doug Evans
2010-02-08 21:07 ` Tom Tromey
1 sibling, 1 reply; 5+ messages in thread
From: Daniel Jacobowitz @ 2010-02-08 19:56 UTC (permalink / raw)
To: Doug Evans; +Cc: gdb-patches
On Mon, Feb 08, 2010 at 11:29:42AM -0800, Doug Evans wrote:
> Hi.
>
> We had problems with python not being able to find its files.
> This may be specific to installations where gdb and python
> are installed in different places.
>
> 2010-02-08 Doug Evans <dje@google.com>
>
> * configure.ac (--with-python): Define WITH_PYTHON_PATH if
> --with-python arg is a path.
> * config.in: Regenerated.
> * configure: Regenerated.
> * python/python.c (_initialize_python): If configured
> --with-python=/path, pass a fake argv[0] to Py_SetProgramName so
> python can find its files.
I suspect this patch will break relocatability. --with-python is a
path on the build system (for -I and -L), not a path on the host
system.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC] Help python find its files
2010-02-08 19:56 ` Daniel Jacobowitz
@ 2010-02-08 20:05 ` Doug Evans
2010-02-08 20:09 ` Daniel Jacobowitz
0 siblings, 1 reply; 5+ messages in thread
From: Doug Evans @ 2010-02-08 20:05 UTC (permalink / raw)
To: Doug Evans, gdb-patches
On Mon, Feb 8, 2010 at 11:56 AM, Daniel Jacobowitz <dan@codesourcery.com> wrote:
> On Mon, Feb 08, 2010 at 11:29:42AM -0800, Doug Evans wrote:
>> Hi.
>>
>> We had problems with python not being able to find its files.
>> This may be specific to installations where gdb and python
>> are installed in different places.
>>
>> 2010-02-08 Doug Evans <dje@google.com>
>>
>> * configure.ac (--with-python): Define WITH_PYTHON_PATH if
>> --with-python arg is a path.
>> * config.in: Regenerated.
>> * configure: Regenerated.
>> * python/python.c (_initialize_python): If configured
>> --with-python=/path, pass a fake argv[0] to Py_SetProgramName so
>> python can find its files.
>
> I suspect this patch will break relocatability. --with-python is a
> path on the build system (for -I and -L), not a path on the host
> system.
Amazing, or depressing, how I forget such things.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC] Help python find its files
2010-02-08 20:05 ` Doug Evans
@ 2010-02-08 20:09 ` Daniel Jacobowitz
0 siblings, 0 replies; 5+ messages in thread
From: Daniel Jacobowitz @ 2010-02-08 20:09 UTC (permalink / raw)
To: Doug Evans; +Cc: gdb-patches
On Mon, Feb 08, 2010 at 12:04:44PM -0800, Doug Evans wrote:
> Amazing, or depressing, how I forget such things.
It's not the typical scenario :-) You could always add another option.
Actually, I'm not sure relocatability really works... it would depend
on what Python did. I know that for my builds, I have a local patch
to override the Python default paths. But the place I override them
to only has Python modules in it, not the Python libraries or headers.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC] Help python find its files
2010-02-08 19:30 [RFC] Help python find its files Doug Evans
2010-02-08 19:56 ` Daniel Jacobowitz
@ 2010-02-08 21:07 ` Tom Tromey
1 sibling, 0 replies; 5+ messages in thread
From: Tom Tromey @ 2010-02-08 21:07 UTC (permalink / raw)
To: Doug Evans; +Cc: gdb-patches
>>>>> "Doug" == Doug Evans <dje@google.com> writes:
Doug> + Py_SetProgramName(WITH_PYTHON_PATH "/bin/python");
Missing a space before "(".
Tom
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-02-08 21:07 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-08 19:30 [RFC] Help python find its files Doug Evans
2010-02-08 19:56 ` Daniel Jacobowitz
2010-02-08 20:05 ` Doug Evans
2010-02-08 20:09 ` Daniel Jacobowitz
2010-02-08 21:07 ` Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox