Skip to content

Commit

Permalink
Merge pull request #24 from beeware/exec-name
Browse files Browse the repository at this point in the history
Ensure that sys.executable returns the executable name
  • Loading branch information
mhsmith authored Apr 25, 2024
2 parents c6fa1a8 + f4b9d75 commit e079d67
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion {{ cookiecutter.format }}/bootstrap/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ int main(int argc, char *argv[]) {
// Establish where the executable is located;
// other application paths will be computed relative to this location
exe_path = realpath("/proc/self/exe", NULL);
bin_path = dirname(exe_path);
bin_path = dirname(strdup(exe_path));
install_path = dirname(bin_path);
printf("Install path: %s\n", install_path);

Expand Down Expand Up @@ -67,6 +67,14 @@ int main(int argc, char *argv[]) {
Py_ExitStatusException(status);
}

// Set the executable name to match the actual executable
status = PyConfig_SetBytesString(&config, &config.executable, exe_path);
if (PyStatus_Exception(status)) {
// crash_dialog("Unable to set executable name: %s", status.err_msg);
PyConfig_Clear(&config);
Py_ExitStatusException(status);
}

// Determine the app module name. Look for the BRIEFCASE_MAIN_MODULE
// environment variable first; if that exists, we're probably in test
// mode. If it doesn't exist, fall back to the MainModule key in the
Expand Down

0 comments on commit e079d67

Please sign in to comment.