[Lldb-commits] [lldb] r138693 - /lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp
Jim Ingham
jingham at apple.com
Fri Aug 26 18:24:09 PDT 2011
Author: jingham
Date: Fri Aug 26 20:24:08 2011
New Revision: 138693
URL: http://llvm.org/viewvc/llvm-project?rev=138693&view=rev
Log:
Don't change the host's environment, just append our Python Directory
directly to the one in sys.
Modified:
lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp
Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=138693&r1=138692&r2=138693&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original)
+++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Fri Aug 26 20:24:08 2011
@@ -2033,59 +2033,53 @@
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();
More information about the lldb-commits
mailing list