diff options
author | Guido van Rossum <guido@python.org> | 1999-01-27 17:53:11 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1999-01-27 17:53:11 (GMT) |
commit | 54ecc3d24f52ae45ca54a24167e434915c88b60f (patch) | |
tree | 2bc2d15f1e6a6178a992a9ce0b4975697f1ef71b /Modules/getpath.c | |
parent | b5cebfe164fbf6c862e8aa9fb91628d1b8cf76be (diff) | |
download | cpython-54ecc3d24f52ae45ca54a24167e434915c88b60f.zip cpython-54ecc3d24f52ae45ca54a24167e434915c88b60f.tar.gz cpython-54ecc3d24f52ae45ca54a24167e434915c88b60f.tar.bz2 |
Patches by William Lewis for Nextstep descendants.
Diffstat (limited to 'Modules/getpath.c')
-rw-r--r-- | Modules/getpath.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/Modules/getpath.c b/Modules/getpath.c index 09b795d..78b4915 100644 --- a/Modules/getpath.c +++ b/Modules/getpath.c @@ -42,6 +42,10 @@ PERFORMANCE OF THIS SOFTWARE. #include <unistd.h> #endif /* HAVE_UNISTD_H */ +#ifdef WITH_NEXT_FRAMEWORK +#include <mach-o/dyld.h> +#endif + /* Search in some common locations for the associated Python libraries. * * Two directories must be found, the platform independent directory @@ -394,7 +398,24 @@ calculate_path() int bufsz; int prefixsz; char *defpath = pythonpath; - +#ifdef WITH_NEXT_FRAMEWORK + NSModule pythonModule; +#endif + +#ifdef WITH_NEXT_FRAMEWORK + pythonModule = NSModuleForSymbol(NSLookupAndBindSymbol("_Py_Initialize")); + /* Use dylib functions to find out where the framework was loaded from */ + buf = NSLibraryNameForModule(pythonModule); + if (buf != NULL) { + /* We're in a framework. */ + strcpy(progpath, buf); + + /* Frameworks have support for versioning */ + strcpy(lib_python, "lib"); + } else { + /* If we're not in a framework, fall back to the old way (even though NSNameOfModule() probably does the same thing.) */ +#endif + /* Initialize this dynamically for K&R C */ sprintf(lib_python, "lib/python%s", VERSION); @@ -430,6 +451,9 @@ calculate_path() } else progpath[0] = '\0'; +#ifdef WITH_NEXT_FRAMEWORK + } +#endif strcpy(argv0_path, progpath); |