Changed logic for finding python home in Mac OS X framework Pythons.

Now sys.executable points to the executable again, in stead of to
the shared library. The latter is used only for locating the python
home.
This commit is contained in:
Jack Jansen 2001-12-02 23:56:28 +00:00
parent 398c236c1b
commit 55070f5d96
1 changed files with 45 additions and 47 deletions

View File

@ -374,38 +374,6 @@ calculate_path(void)
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. */
/* See if we might be in the build directory. The framework in the
** build directory is incomplete, it only has the .dylib and a few
** needed symlinks, it doesn't have the Lib directories and such.
** If we're running with the framework from the build directory we must
** be running the interpreter in the build directory, so we use the
** build-directory-specific logic to find Lib and such.
*/
strncpy(argv0_path, buf, MAXPATHLEN);
reduce(argv0_path);
joinpath(argv0_path, lib_python);
joinpath(argv0_path, LANDMARK);
if (!ismodule(argv0_path)) {
/* We are in the build directory so use the name of the
executable - we know that the absolute path is passed */
strncpy(progpath, prog, MAXPATHLEN);
}
else {
/* Use the location of the library as the progpath */
strncpy(progpath, buf, MAXPATHLEN);
}
}
else {
/* If we're not in a framework, fall back to the old way
(even though NSNameOfModule() probably does the same thing.) */
#endif
/* If there is no slash in the argv0 path, then we have to
* assume python is on the user's $PATH, since there's no
* other way to find a directory to start the search from. If
@ -442,12 +410,42 @@ calculate_path(void)
progpath[0] = '\0';
if (progpath[0] != SEP)
absolutize(progpath);
strncpy(argv0_path, progpath, MAXPATHLEN);
#ifdef WITH_NEXT_FRAMEWORK
/* 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 */
buf = NSLibraryNameForModule(pythonModule);
if (buf != NULL) {
/* We're in a framework. */
/* See if we might be in the build directory. The framework in the
** build directory is incomplete, it only has the .dylib and a few
** needed symlinks, it doesn't have the Lib directories and such.
** If we're running with the framework from the build directory we must
** be running the interpreter in the build directory, so we use the
** build-directory-specific logic to find Lib and such.
*/
strncpy(argv0_path, buf, MAXPATHLEN);
reduce(argv0_path);
joinpath(argv0_path, lib_python);
joinpath(argv0_path, LANDMARK);
if (!ismodule(argv0_path)) {
/* We are in the build directory so use the name of the
executable - we know that the absolute path is passed */
strncpy(argv0_path, prog, MAXPATHLEN);
}
else {
/* Use the location of the library as the progpath */
strncpy(argv0_path, buf, MAXPATHLEN);
}
}
#endif
strncpy(argv0_path, progpath, MAXPATHLEN);
#if HAVE_READLINK
{
char tmpbuffer[MAXPATHLEN+1];