Skip to content

Commit f8fe46d

Browse files
Actually calculate absolute home dir
1 parent 2468c46 commit f8fe46d

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

source/main.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,23 @@ int main(int argc, char *argv[])
2323
Py_NoUserSiteDirectory = 1;
2424
//Py_VerboseFlag += 1;
2525

26-
Py_SetPythonHome(L"./");
26+
/* Calculate absolute home dir */
27+
char cwd[PATH_MAX];
28+
getcwd(cwd, sizeof(cwd));
29+
/* Strip the leading sdmc: to workaround a bug somewhere... */
30+
char *stripped_cwd = strchr(cwd, '/');
31+
if (stripped_cwd == NULL) stripped_cwd = cwd;
32+
33+
Py_SetPythonHome(Py_DecodeLocale(stripped_cwd, NULL));
2734

2835
Py_Initialize();
29-
36+
3037
/* Print some info */
3138
printf("Python %s on %s\n", Py_GetVersion(), Py_GetPlatform());
3239

3340
/* set up import path */
34-
char cwd[PATH_MAX];
35-
getcwd(cwd, sizeof(cwd));
36-
/* Strip the leading sdmc: to workaround a bug somewhere... */
37-
char *stripped_cwd = strchr(cwd, '/');
38-
if (stripped_cwd == NULL) stripped_cwd = cwd;
3941
PyObject *sysPath = PySys_GetObject("path");
40-
PyObject *path = PyUnicode_FromString(cwd);
42+
PyObject *path = PyUnicode_FromString(stripped_cwd);
4143
PyList_Insert(sysPath, 0, path);
4244

4345
FILE * mainpy = fopen(MAINPY, "r");

0 commit comments

Comments
 (0)