summaryrefslogtreecommitdiffstats
path: root/ui-macos/bits/runpython.c
blob: 63de339ee383a50d5396447dfa6c2e17ad1d0ec5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*
 * This rather pointless program acts like the python interpreter, except
 * it's intended to sit inside a MacOS .app package, so that its argv[0]
 * will point inside the package.
 *
 * NSApplicationMain() looks for Info.plist using the path in argv[0], which
 * goes wrong if your interpreter is /usr/bin/python.
 */
#include <Python.h>
#include <string.h>
#include <unistd.h>

int main(int argc, char **argv)
{
    char *path = strdup(argv[0]), *cptr;
    char *args[] = {argv[0], "../Resources/main.py", NULL};
    cptr = strrchr(path, '/');
    if (cptr)
	*cptr = 0;
    chdir(path);
    free(path);
    return Py_Main(2, args);
}