Skip to content

Commit c05ad3b

Browse files
committed
Update 1 code files
Modified: • src/omnipkg/dispatcher.c (+17/-11 lines) [gitship-generated]
1 parent 13bc84f commit c05ad3b

1 file changed

Lines changed: 16 additions & 10 deletions

File tree

src/omnipkg/dispatcher.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -982,9 +982,16 @@ static void fallback_to_python_v(const char *self_dir, char **argv,
982982
if (file_exists(py)) { found = 1; break; }
983983
}
984984

985-
/* 2. CROSS-DRIVE FIX: If still not found, ask Windows where 'python' is */
985+
/* 2. SYSTEM LOOKUP: Use OS-specific popen to find python */
986986
if (!found) {
987-
FILE *fp = _popen("where python", "r");
987+
FILE *fp = NULL;
988+
989+
#ifdef _WIN32
990+
fp = _popen("where python", "r");
991+
#else
992+
fp = popen("which python", "r");
993+
#endif
994+
988995
if (fp) {
989996
if (fgets(py, sizeof(py), fp)) {
990997
// Remove newline characters
@@ -993,7 +1000,12 @@ static void fallback_to_python_v(const char *self_dir, char **argv,
9931000
found = 1;
9941001
}
9951002
}
996-
_pclose(fp);
1003+
1004+
#ifdef _WIN32
1005+
_pclose(fp);
1006+
#else
1007+
pclose(fp);
1008+
#endif
9971009
}
9981010
}
9991011

@@ -1002,14 +1014,8 @@ static void fallback_to_python_v(const char *self_dir, char **argv,
10021014
fprintf(stderr, " Self Dir: %s\n", self_dir);
10031015
exit(1);
10041016
}
1005-
/* VERBOSE DIAGNOSTICS: Tell the user EXACTLY where we looked */
1006-
fprintf(stderr, "omnipkg: cannot find host Python for fallback\n");
1007-
fprintf(stderr, " Checked directory: %s\n", self_dir);
1008-
fprintf(stderr, " Tried common names in current and parent dirs\n");
1009-
exit(1);
1010-
}
10111017

1012-
/* Build new argv: python -m omnipkg.dispatcher <original args> */
1018+
/* ... (Rest of the execv logic remains the same) ... */
10131019
int argc = 0;
10141020
while (argv[argc]) argc++;
10151021
char **new_argv = malloc((argc + 4) * sizeof(char *));

0 commit comments

Comments
 (0)