bpo-45582: Fix framework path and bootstrap build by tiran · Pull Request #29954 · python/cpython
/* On Mac OS X we have a special case if we're running from a framework. This is because the python home should be set relative to the library, which is in the framework, not relative to the executable, which may be outside of the framework. Except when we're in the build directory... */ pythonModule = NSModuleForSymbol(NSLookupAndBindSymbol("_Py_Initialize"));
/* Use dylib functions to find out where the framework was loaded from */ const char *path = NSLibraryNameForModule(pythonModule); if (path) { strncpy(modPath, path, MAXPATHLEN); NSSymbol symbol = NSLookupAndBindSymbol("_Py_Initialize"); if (symbol != NULL) { NSModule pythonModule = NSModuleForSymbol(symbol); if (pythonModule != NULL) { /* Use dylib functions to find out where the framework was loaded from */ const char *path = NSLibraryNameForModule(pythonModule); if (path) { strncpy(modPath, path, MAXPATHLEN); modPathInitialized = 1; } } } } if (modPathInitialized > 0) {