Skip to content

Commit ada0568

Browse files
Calculate absolute import path
1 parent 8b7c0ee commit ada0568

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

source/main.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,13 @@ int main(int argc, char *argv[])
3131
printf("Python %s on %s\n", Py_GetVersion(), Py_GetPlatform());
3232

3333
/* 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;
3439
PyObject *sysPath = PySys_GetObject("path");
35-
PyObject *path = PyUnicode_FromString("./");
40+
PyObject *path = PyUnicode_FromString(cwd);
3641
PyList_Insert(sysPath, 0, path);
3742

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

0 commit comments

Comments
 (0)