mirror of
https://github.com/cemu-project/idapython.git
synced 2024-12-29 03:01:52 +01:00
fix for the $PATH issue on OSX by setting proper home path (thanks to igorsk)
This commit is contained in:
parent
15a72289f7
commit
c1d87c0c7c
25
python.cpp
25
python.cpp
@ -23,6 +23,9 @@
|
|||||||
#ifdef __LINUX__
|
#ifdef __LINUX__
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef __MAC__
|
||||||
|
#include <mach-o/dyld.h>
|
||||||
|
#endif
|
||||||
#include <ida.hpp>
|
#include <ida.hpp>
|
||||||
#include <idp.hpp>
|
#include <idp.hpp>
|
||||||
#include <ieee.h>
|
#include <ieee.h>
|
||||||
@ -1208,6 +1211,28 @@ bool IDAPython_Init(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __MAC__
|
||||||
|
// We should set python home to the module's path, otherwise it can pick up stray modules from $PATH
|
||||||
|
NSModule pythonModule = NSModuleForSymbol(NSLookupAndBindSymbol("_Py_Initialize"));
|
||||||
|
// Use dylib functions to find out where the framework was loaded from
|
||||||
|
const char *buf = (char *)NSLibraryNameForModule(pythonModule);
|
||||||
|
if ( buf != NULL )
|
||||||
|
{
|
||||||
|
// The path will be something like:
|
||||||
|
// /System/Library/Frameworks/Python.framework/Versions/2.5/Python
|
||||||
|
// We need to strip the last part
|
||||||
|
// use static buffer because Py_SetPythonHome() just stores a pointer
|
||||||
|
static char pyhomepath[MAXSTR];
|
||||||
|
qstrncpy(pyhomepath, buf, MAXSTR);
|
||||||
|
char * lastslash = strrchr(pyhomepath, '/');
|
||||||
|
if ( lastslash != NULL )
|
||||||
|
{
|
||||||
|
*lastslash = 0;
|
||||||
|
Py_SetPythonHome(pyhomepath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Start the interpreter
|
// Start the interpreter
|
||||||
Py_Initialize();
|
Py_Initialize();
|
||||||
if ( !Py_IsInitialized() )
|
if ( !Py_IsInitialized() )
|
||||||
|
Loading…
Reference in New Issue
Block a user