diff options
| author | Patrick Storz <eduard.braun2@gmx.de> | 2019-06-13 21:20:33 +0000 |
|---|---|---|
| committer | Patrick Storz <eduard.braun2@gmx.de> | 2019-06-14 20:29:27 +0000 |
| commit | 370c52d1310a0d86e4d0c4ad125209f320918d54 (patch) | |
| tree | b942def4631382449b42cf9798702c1246ec7009 /src/inkscape-main.cpp | |
| parent | append_inkscape_datadir: Always canonicalize full filename (diff) | |
| download | inkscape-370c52d1310a0d86e4d0c4ad125209f320918d54.tar.gz inkscape-370c52d1310a0d86e4d0c4ad125209f320918d54.zip | |
Add extensions directory in user folder to PYTHONPATH
This allows users to install modules there and use them easily
within other modules (for example required for extension manager)
Diffstat (limited to 'src/inkscape-main.cpp')
| -rw-r--r-- | src/inkscape-main.cpp | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/src/inkscape-main.cpp b/src/inkscape-main.cpp index 8473795c1..17f044edb 100644 --- a/src/inkscape-main.cpp +++ b/src/inkscape-main.cpp @@ -17,6 +17,8 @@ #include "inkscape-application.h" #include "path-prefix.h" +#include "io/resource.h" + static void set_extensions_env() { // add inkscape to PATH, so the correct version is always available to extensions by simply calling "inkscape" @@ -29,27 +31,23 @@ static void set_extensions_env() } g_free(program_dir); - // add share/inkscape/extensions to PYTHONPATH so the inkex module is found by extensions in user folder - auto new_pythonpath = std::string(INKSCAPE_EXTENSIONDIR); + // add various locations to PYTHONPATH so extensions find their modules + auto extensiondir_user = get_path_ustring(Inkscape::IO::Resource::USER, Inkscape::IO::Resource::EXTENSIONS); + auto extensiondir_system = get_path_ustring(Inkscape::IO::Resource::SYSTEM, Inkscape::IO::Resource::EXTENSIONS); + + auto pythonpath = extensiondir_user + G_SEARCHPATH_SEPARATOR + extensiondir_system; - // add old PYTHONPATH - gchar const *pythonpath = g_getenv("PYTHONPATH"); - if (pythonpath) { - new_pythonpath.append(G_SEARCHPATH_SEPARATOR_S).append(pythonpath); + auto pythonpath_old = Glib::getenv("PYTHONPATH"); + if (!pythonpath_old.empty()) { + pythonpath += G_SEARCHPATH_SEPARATOR + pythonpath_old; } - // add share/inkscape/extensions/inkex/deprecated-simple - new_pythonpath.append(G_SEARCHPATH_SEPARATOR_S) - .append(INKSCAPE_EXTENSIONDIR) - .append(G_DIR_SEPARATOR_S) - .append("inkex") - .append(G_DIR_SEPARATOR_S) - .append("deprecated-simple"); + pythonpath += G_SEARCHPATH_SEPARATOR + Glib::build_filename(extensiondir_system, "inkex", "deprecated-simple"); - g_setenv("PYTHONPATH", new_pythonpath.c_str(), true); + Glib::setenv("PYTHONPATH", pythonpath); // Python 2.x attempts to encode output as ASCII by default when sent to a pipe. - g_setenv("PYTHONIOENCODING", "UTF-8", true); + Glib::setenv("PYTHONIOENCODING", "UTF-8"); #ifdef _WIN32 // add inkscape directory to DLL search path so dynamically linked extension modules find their libraries |
