diff --git a/docs/changelog.rst b/docs/changelog.rst index cecd3a3a8..231c8b1ba 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -27,6 +27,9 @@ To update |kitty|, :doc:`follow the instructions `. - Fix selections created by dragging upwards not being auto-cleared when screen contents change (:pull:`3028`) +- macOS: Fix kitty not being added to PATH automatically when using pre-built + binaries (:iss:`3063`) + - Allow adding MIME definitions to kitty by placing a ``mime.types`` file in the kitty config directory (:iss:`3056`) diff --git a/launcher.c b/launcher.c index 2f077ae35..eb307cd49 100644 --- a/launcher.c +++ b/launcher.c @@ -42,10 +42,11 @@ safe_realpath(const char* src, char *buf, size_t buf_sz) { #endif static inline void -set_xoptions(const wchar_t *exe_dir, const char *lc_ctype) { +set_xoptions(const wchar_t *exe_dir, const char *lc_ctype, bool from_source) { wchar_t buf[PATH_MAX+1] = {0}; swprintf(buf, PATH_MAX, L"bundle_exe_dir=%ls", exe_dir); PySys_AddXOption(buf); + if (from_source) PySys_AddXOption(L"kitty_from_source=1"); if (lc_ctype) { swprintf(buf, PATH_MAX, L"lc_ctype_before_python=%s", lc_ctype); PySys_AddXOption(buf); @@ -66,7 +67,6 @@ static int run_embedded(const char* exe_dir_, const char *libpath, int argc, wch int ret = 1; wchar_t *exe_dir = Py_DecodeLocale(exe_dir_, NULL); if (exe_dir == NULL) { fprintf(stderr, "Fatal error: cannot decode exe_dir\n"); return 1; } - set_xoptions(exe_dir, lc_ctype); wchar_t stdlib[PATH_MAX+1] = {0}; #ifdef __APPLE__ const char *python_relpath = "../Resources/Python/lib"; @@ -80,9 +80,9 @@ static int run_embedded(const char* exe_dir_, const char *libpath, int argc, wch ); if (num < 0 || num >= PATH_MAX) { fprintf(stderr, "Failed to create path to python stdlib\n"); return 1; } Py_SetPath(stdlib); - PyMem_RawFree(exe_dir); - if (num < 0 || num >= PATH_MAX) { fprintf(stderr, "Failed to create path to kitty lib\n"); return 1; } Py_Initialize(); + set_xoptions(exe_dir, lc_ctype, false); + PyMem_RawFree(exe_dir); PySys_SetArgvEx(argc - 1, argv + 1, 0); PySys_SetObject("frozen", Py_True); PyObject *kitty = PyUnicode_FromString(libpath); @@ -104,10 +104,11 @@ static int run_embedded(const char* exe_dir_, const char *libpath, int argc, wch (void)libpath; wchar_t *exe_dir = Py_DecodeLocale(exe_dir_, NULL); if (exe_dir == NULL) { fprintf(stderr, "Fatal error: cannot decode exe_dir: %s\n", exe_dir_); return 1; } - set_xoptions(exe_dir, lc_ctype); + bool from_source = false; #ifdef FROM_SOURCE - PySys_AddXOption(L"kitty_from_source=1"); + from_source = true; #endif + set_xoptions(exe_dir, lc_ctype, from_source); PyMem_RawFree(exe_dir); return Py_Main(argc, argv); }