diff options
| author | Jim Ingham <jingham@apple.com> | 2011-08-27 01:24:08 +0000 |
|---|---|---|
| committer | Jim Ingham <jingham@apple.com> | 2011-08-27 01:24:08 +0000 |
| commit | a6c422b7de36934bd6e83b955486dcd4380305ba (patch) | |
| tree | 5376e74c688d48779abbd7f62ca18b89a675f816 /lldb/source/Interpreter/ScriptInterpreterPython.cpp | |
| parent | 650543f9ba62022daea1c498a1627a160afc15cc (diff) | |
| download | bcm5719-llvm-a6c422b7de36934bd6e83b955486dcd4380305ba.tar.gz bcm5719-llvm-a6c422b7de36934bd6e83b955486dcd4380305ba.zip | |
Don't change the host's environment, just append our Python Directory
directly to the one in sys.
llvm-svn: 138693
Diffstat (limited to 'lldb/source/Interpreter/ScriptInterpreterPython.cpp')
| -rw-r--r-- | lldb/source/Interpreter/ScriptInterpreterPython.cpp | 48 |
1 files changed, 21 insertions, 27 deletions
diff --git a/lldb/source/Interpreter/ScriptInterpreterPython.cpp b/lldb/source/Interpreter/ScriptInterpreterPython.cpp index fe1fe2302ad..0f508de7c5d 100644 --- a/lldb/source/Interpreter/ScriptInterpreterPython.cpp +++ b/lldb/source/Interpreter/ScriptInterpreterPython.cpp @@ -2033,59 +2033,53 @@ ScriptInterpreterPython::InitializePrivate () TerminalState stdin_tty_state; stdin_tty_state.Save(STDIN_FILENO, false); + PyEval_InitThreads (); + Py_InitializeEx (0); + + // Initialize SWIG after setting up python + assert (g_swig_init_callback != NULL); + g_swig_init_callback (); + + // Update the path python uses to search for modules to include the current directory. + + PyRun_SimpleString ("import sys"); + PyRun_SimpleString ("sys.path.append ('.')"); + // Find the module that owns this code and use that path we get to - // set the PYTHONPATH appropriately. + // set the sys.path appropriately. FileSpec file_spec; char python_dir_path[PATH_MAX]; if (Host::GetLLDBPath (ePathTypePythonDir, file_spec)) { - std::string python_path; - const char *curr_python_path = ::getenv ("PYTHONPATH"); - if (curr_python_path) - { - // We have a current value for PYTHONPATH, so lets append to it - python_path.append (curr_python_path); - } - + std::string python_path("sys.path.insert(0,\""); + size_t orig_len = python_path.length(); if (file_spec.GetPath(python_dir_path, sizeof (python_dir_path))) { - if (!python_path.empty()) - python_path.append (1, ':'); python_path.append (python_dir_path); + python_path.append ("\")"); + PyRun_SimpleString (python_path.c_str()); + python_path.resize (orig_len); } if (Host::GetLLDBPath (ePathTypeLLDBShlibDir, file_spec)) { if (file_spec.GetPath(python_dir_path, sizeof (python_dir_path))) { - if (!python_path.empty()) - python_path.append (1, ':'); python_path.append (python_dir_path); + python_path.append ("\")"); + PyRun_SimpleString (python_path.c_str()); + python_path.resize (orig_len); } } - const char *pathon_path_env_cstr = python_path.c_str(); - ::setenv ("PYTHONPATH", pathon_path_env_cstr, 1); } - PyEval_InitThreads (); - Py_InitializeEx (0); - - // Initialize SWIG after setting up python - assert (g_swig_init_callback != NULL); - g_swig_init_callback (); - - // Update the path python uses to search for modules to include the current directory. - - PyRun_SimpleString ("import sys"); - PyRun_SimpleString ("sys.path.append ('.')"); PyRun_SimpleString ("sys.dont_write_bytecode = 1"); PyRun_SimpleString ("import embedded_interpreter"); PyRun_SimpleString ("from embedded_interpreter import run_python_interpreter"); PyRun_SimpleString ("from embedded_interpreter import run_one_line"); - PyRun_SimpleString ("import sys"); PyRun_SimpleString ("from termios import *"); stdin_tty_state.Restore(); |

