From: Krzysztof KosiƄski Date: Tue, 30 Mar 2010 16:05:21 +0000 (+0200) Subject: Make all paths in PYTHONPATH absolute. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=d3915dd7c0e58110960c9256e5ca33f22bc5e2de;p=inkscape.git Make all paths in PYTHONPATH absolute. --- diff --git a/src/main.cpp b/src/main.cpp index cd60d9fa1..32102f3b3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -552,6 +552,19 @@ static void set_extensions_env() #else extdir = g_strdup(INKSCAPE_EXTENSIONDIR); #endif + + // On some platforms, INKSCAPE_EXTENSIONDIR is not absolute, + // but relative to the directory that contains the Inkscape executable. + // Since we spawn Python chdir'ed into the script's directory, + // we need to obtain the absolute path here. + if (!g_path_is_absolute(extdir)) { + gchar *curdir = g_get_current_dir(); + gchar *extdir_new = g_build_filename(curdir, extdir, NULL); + g_free(extdir); + g_free(curdir); + extdir = extdir_new; + } + if (pythonpath) { new_pythonpath = g_strdup_printf("%s" G_SEARCHPATH_SEPARATOR_S "%s", extdir, pythonpath); @@ -562,7 +575,7 @@ static void set_extensions_env() g_setenv("PYTHONPATH", new_pythonpath, TRUE); g_free(new_pythonpath); - printf("PYTHONPATH = %s", g_getenv("PYTHONPATH")); + printf("PYTHONPATH = %s\n", g_getenv("PYTHONPATH")); } /** @@ -588,7 +601,6 @@ main(int argc, char **argv) HKCR\svgfile\shell\open\command is a good example TODO: this breaks the CLI on Windows, see LP #167455 - However, the CLI is broken anyway, because we are a GUI app */ const int pathbuf = 2048; gunichar2 *path = g_new(gunichar2, pathbuf);