Skip to content

Commit e925faf

Browse files
committed
With WITH_NEXT_FRAMEWORK defined we now also expect a normal Python
installation. If there is no LANDMARK we assume we're a bare framework in the install directory (again WITH_NEXT_FRAMEWORK only).
1 parent f5bf77c commit e925faf

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

Modules/getpath.c

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/* Return the initial module search path. */
32

43
#include "Python.h"
@@ -371,16 +370,31 @@ calculate_path(void)
371370
#endif
372371

373372
#ifdef WITH_NEXT_FRAMEWORK
374-
/* XXX Need to check this code for buffer overflows */
375373
pythonModule = NSModuleForSymbol(NSLookupAndBindSymbol("_Py_Initialize"));
376374
/* Use dylib functions to find out where the framework was loaded from */
377375
buf = NSLibraryNameForModule(pythonModule);
378376
if (buf != NULL) {
379377
/* We're in a framework. */
380-
strcpy(progpath, buf);
381-
382-
/* Frameworks have support for versioning */
383-
strcpy(lib_python, "lib");
378+
/* See if we might be in the build directory. The framework in the
379+
** build directory is incomplete, it only has the .dylib and a few
380+
** needed symlinks, it doesn't have the Lib directories and such.
381+
** If we're running with the framework from the build directory we must
382+
** be running the interpreter in the build directory, so we use the
383+
** build-directory-specific logic to find Lib and such.
384+
*/
385+
strncpy(argv0_path, buf, MAXPATHLEN);
386+
reduce(argv0_path);
387+
joinpath(argv0_path, lib_python);
388+
joinpath(argv0_path, LANDMARK);
389+
if (!ismodule(argv0_path)) {
390+
/* We are in the build directory so use the name of the
391+
executable - we know that the absolute path is passed */
392+
strncpy(progpath, prog, MAXPATHLEN);
393+
}
394+
else {
395+
/* Use the location of the library as the progpath */
396+
strncpy(progpath, buf, MAXPATHLEN);
397+
}
384398
}
385399
else {
386400
/* If we're not in a framework, fall back to the old way

0 commit comments

Comments
 (0)