--- /dev/null
+For macOS framework builds, in ``getpath.c`` use the system ``dladdr``
+function to find the path to the shared library rather than depending
+on deprecated macOS APIs.
+
#endif
#ifdef __APPLE__
-# include <mach-o/dyld.h>
+# include <dlfcn.h>
#endif
/* Reference the precompiled getpath.py */
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... */
- 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;
- }
+ Dl_info pythonInfo;
+ if (dladdr(&Py_Initialize, &pythonInfo)) {
+ if (pythonInfo.dli_fname) {
+ strncpy(modPath, pythonInfo.dli_fname, MAXPATHLEN);
+ modPathInitialized = 1;
}
}
}