From e371dc32a94b0c4ffe7192aad634b425b5b43437 Mon Sep 17 00:00:00 2001 From: Steve Reinhardt Date: Tue, 30 May 2006 19:44:57 -0400 Subject: Clean up Python embedding to build on zizzer (where python2.4 is currently in /usr/local instead of /usr). SConstruct: Use information from the Python interpreter used to run scons to find the version & paths for include & library files. This means that linking with a different interpreter requires invoking scons with that interpreter... add comment to that effect. src/sim/main.cc: Check return codes of Python interpreter calls for errors. Get rid of include of obsolete header. --HG-- extra : convert_revision : 90916bd8690fe1e6c9afdb0dfa1aa0d352a73a46 --- src/sim/main.cc | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/sim/main.cc b/src/sim/main.cc index a4e8a1f77..430dd8f3a 100644 --- a/src/sim/main.cc +++ b/src/sim/main.cc @@ -146,8 +146,6 @@ echoCommandLine(int argc, char **argv, ostream &out) out << endl << endl; } -#include "config/python_build_env.hh" - int main(int argc, char **argv) { @@ -171,20 +169,25 @@ main(int argc, char **argv) // Set Python module path to include current file to find embedded // zip archive - PyRun_SimpleString("import sys"); + if (PyRun_SimpleString("import sys") != 0) + panic("Python error importing 'sys' module\n"); string pathCmd = csprintf("sys.path[1:1] = ['%s']", fileName); - PyRun_SimpleString(pathCmd.c_str()); + if (PyRun_SimpleString(pathCmd.c_str()) != 0) + panic("Python error setting sys.path\n"); // Pass compile timestamp string to Python extern const char *compileDate; // from date.cc string setCompileDate = csprintf("compileDate = '%s'", compileDate); - PyRun_SimpleString(setCompileDate.c_str()); + if (PyRun_SimpleString(setCompileDate.c_str()) != 0) + panic("Python error setting compileDate\n"); // PyRun_InteractiveLoop(stdin, "stdin"); // m5/__init__.py currently contains main argv parsing loop etc., // and will write out config.ini file before returning. - PyImport_ImportModule("defines"); - PyImport_ImportModule("m5"); + if (PyImport_ImportModule("defines") == NULL) + panic("Python error importing 'defines.py'\n"); + if (PyImport_ImportModule("m5") == NULL) + panic("Python error importing 'm5' module\n"); Py_Finalize(); configStream = simout.find("config.out"); -- cgit v1.2.3