This is the mail archive of the
archer@sourceware.org
mailing list for the Archer project.
[python] update Python's sys.path
- From: Tom Tromey <tromey at redhat dot com>
- To: Project Archer <archer at sourceware dot org>
- Date: Tue, 18 Nov 2008 13:13:25 -0700
- Subject: [python] update Python's sys.path
- Reply-to: Tom Tromey <tromey at redhat dot com>
This patch causes gdb to update Python's sys.path at startup.
Now, files installed into gdb's data dir will be automatically found.
Tom
2008-11-18 Tom Tromey <tromey@redhat.com>
* python/python.c (_initialize_python): Add gdb path to sys.path.
diff --git a/gdb/python/python.c b/gdb/python/python.c
index 340213f..989afdb 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -1256,6 +1256,7 @@ Enables or disables auto-loading of Python code when an object is opened."),
PyModule_AddStringConstant (gdb_module, "VERSION", (char*) version);
PyModule_AddStringConstant (gdb_module, "HOST_CONFIG", (char*) host_name);
PyModule_AddStringConstant (gdb_module, "TARGET_CONFIG", (char*) target_name);
+ PyModule_AddStringConstant (gdb_module, "datadir", gdb_datadir);
gdbpy_initialize_values ();
gdbpy_initialize_breakpoints ();
@@ -1303,6 +1304,7 @@ class GdbOutputFile:\n\
\n\
sys.stderr = GdbOutputFile()\n\
sys.stdout = GdbOutputFile()\n\
+sys.path.insert(0, gdb.datadir)\n\
");
/* Release the GIL while gdb runs. */