rename all of the python3 source files to have python3 in their name
--- a/python/gplugin-python-core.c Sat Feb 22 03:33:17 2020 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
- * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com>
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, see <http://www.gnu.org/licenses/>.
-#include <gplugin-native.h>
-#include <glib/gi18n-lib.h>
-#include "gplugin-python-loader.h"
-#include "gplugin-python-plugin.h"
-G_MODULE_EXPORT GPluginPluginInfo *
-gplugin_query(G_GNUC_UNUSED GError **error) {
- const gchar * const authors[] = {
- "Gary Kramlich <grim@reaperworld.com>",
- return gplugin_plugin_info_new(
- "gplugin/python3-loader",
- GPLUGIN_NATIVE_PLUGIN_ABI_VERSION,
- "name", "Python Plugin Loader",
- "version", GPLUGIN_VERSION,
- "license-id", "LGPL-2.0-or-later",
- "summary", "A plugin that can load python plugins",
- "description", "This plugin allows the loading of plugins written in "
- "the python programming language.",
- "website", GPLUGIN_WEBSITE,
-G_MODULE_EXPORT gboolean
-gplugin_load(GPluginNativePlugin *plugin,
- G_GNUC_UNUSED GError **error)
- gplugin_python_plugin_register(plugin);
- gplugin_python_loader_register(plugin);
- gplugin_manager_register_loader(GPLUGIN_PYTHON_TYPE_LOADER);
-G_MODULE_EXPORT gboolean
-gplugin_unload(G_GNUC_UNUSED GPluginNativePlugin *plugin,
- _("The Python loader can not be unloaded")
--- a/python/gplugin-python-loader.c Sat Feb 22 03:33:17 2020 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,373 +0,0 @@
- * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com>
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, see <http://www.gnu.org/licenses/>.
-#include "gplugin-python-loader.h"
-#include "gplugin-python-plugin.h"
-#include "gplugin-python-utils.h"
-#include <glib/gi18n-lib.h>
-struct _GPluginPythonLoader {
- PyThreadState *py_thread_state;
-G_DEFINE_DYNAMIC_TYPE(GPluginPythonLoader, gplugin_python_loader, GPLUGIN_TYPE_LOADER);
-/******************************************************************************
- * GPluginLoader Implementation
- *****************************************************************************/
-gplugin_python_loader_class_supported_extensions(G_GNUC_UNUSED GPluginLoaderClass *klass) {
- return g_slist_append(NULL, "py");
-gplugin_python_loader_query(GPluginLoader *loader,
- G_GNUC_UNUSED GError **error)
- GPluginPlugin *plugin = NULL;
- PyObject *pyinfo = NULL, *args = NULL;
- PyObject *module = NULL, *package_list = NULL, *module_dict = NULL;
- PyObject *query = NULL, *load = NULL, *unload = NULL;
- PyGILState_STATE state;
- gchar *module_name = NULL, *dir_name = NULL;
- state = pyg_gil_state_ensure();
- /* create package_list as a tuple to handle 'import foo.bar' */
- package_list = PyTuple_New(0);
- /* now figure out the module name from the filename */
- module_name = gplugin_python_filename_to_module(filename);
- /* grab the dirname since we need it on sys.path to import the module */
- dir_name = g_path_get_dirname(filename);
- gplugin_python_add_module_path(dir_name);
- /* import the module */
- module = PyImport_ImportModuleEx(module_name, NULL, NULL, package_list);
- g_warning(_("Failed to query %s"), filename);
- /* clean some stuff up */
- Py_DECREF(package_list);
- pyg_gil_state_release(state);
- /* clean some stuff up */
- Py_DECREF(package_list);
- /* at this point we have the module, lets find the query, load, and unload
- module_dict = PyModule_GetDict(module);
- query = PyDict_GetItemString(module_dict, "gplugin_query");
- g_warning(_("Failed to find the gplugin_query function in %s"),
- pyg_gil_state_release(state);
- if(!PyCallable_Check(query)) {
- g_warning(_("Found gplugin_query in %s but it is not a "
- pyg_gil_state_release(state);
- load = PyDict_GetItemString(module_dict, "gplugin_load");
- g_warning(_("Failed to find the gplugin_load function in %s"),
- pyg_gil_state_release(state);
- if(!PyCallable_Check(load)) {
- g_warning(_("Found gplugin_load in %s but it is not a "
- pyg_gil_state_release(state);
- unload = PyDict_GetItemString(module_dict, "gplugin_unload");
- g_warning(_("Failed to find the gplugin_unload function in %s"),
- pyg_gil_state_release(state);
- if(!PyCallable_Check(unload)) {
- g_warning(_("Found gplugin_unload in %s but it is not a "
- pyg_gil_state_release(state);
- /* now that we have everything, call the query method and get the plugin's
- pyinfo = PyObject_Call(query, args, NULL);
- info = pygobject_get(pyinfo);
- /* now that we have everything, create the plugin */
- plugin = g_object_new(GPLUGIN_PYTHON_TYPE_PLUGIN,
- pyg_gil_state_release(state);
-gplugin_python_loader_load(G_GNUC_UNUSED GPluginLoader *loader,
- PyObject *load = NULL, *pyplugin = NULL, *result = NULL;
- g_object_get(G_OBJECT(plugin), "load-func", &load, NULL);
- pyplugin = pygobject_new(G_OBJECT(plugin));
- result = PyObject_CallFunctionObjArgs(load, pyplugin, NULL);
- if (PyErr_Occurred()) {
- *error = gplugin_python_exception_to_gerror();
- ret = PyObject_IsTrue(result);
- g_set_error_literal(error, GPLUGIN_DOMAIN, 0,
- _("Failed to load plugin"));
-gplugin_python_loader_unload(G_GNUC_UNUSED GPluginLoader *loader,
- PyObject *unload = NULL, *pyplugin = NULL, *result = NULL;
- g_object_get(G_OBJECT(plugin), "unload-func", &unload, NULL);
- pyplugin = pygobject_new(G_OBJECT(plugin));
- result = PyObject_CallFunctionObjArgs(unload, pyplugin, NULL);
- ret = PyObject_IsTrue(result);
- g_set_error_literal(error, GPLUGIN_DOMAIN, 0,
- _("Failed to unload plugin"));
-/******************************************************************************
- *****************************************************************************/
-gplugin_python_loader_init_pygobject(void) {
- pygobject_init(3, 0, 0);
- PyObject *type = NULL, *value = NULL, *tb = NULL, *obj = NULL;
- PyErr_Fetch(&type, &value, &tb);
- obj = PyUnicode_AsUTF8String(value);
- g_warning("Failed to initialize PyGObject : %s", PyBytes_AsString(obj));
- /* disable g_log redirections */
- pyg_disable_warning_redirections();
-gplugin_python_loader_init_gettext(void) {
- PyObject *module_dict = NULL, *install = NULL;
- PyObject *gettext = NULL, *result = NULL;
- gettext = PyImport_ImportModule("gettext");
- g_warning("Failed to import gettext");
- module_dict = PyModule_GetDict(gettext);
- install = PyDict_GetItemString(module_dict, "install");
- result = PyObject_CallFunction(install, "ss", GETTEXT_PACKAGE, LOCALEDIR);
-gplugin_python_loader_init_python(void) {
- wchar_t *argv[] = { NULL, NULL };
- /* Initializes Python */
- if(!Py_IsInitialized())
- Py_InitializeEx(FALSE);
- argv[0] = Py_DecodeLocale(g_get_prgname(), NULL);
- g_warning("Could not convert program name to wchar_t string.");
- /* setup sys.path according to
- * https://docs.python.org/3/c-api/init.html#PySys_SetArgvEx
- PySys_SetArgvEx(1, argv, 0);
- PyMem_RawFree(argv[0]);
- /* initialize pygobject */
- if(gplugin_python_loader_init_pygobject()) {
- if(gplugin_python_loader_init_gettext()) {
-/******************************************************************************
- *****************************************************************************/
-gplugin_python_loader_init(G_GNUC_UNUSED GPluginPythonLoader *loader) {
-gplugin_python_loader_class_finalize(G_GNUC_UNUSED GPluginPythonLoaderClass *klass)
-gplugin_python_loader_class_init(GPluginPythonLoaderClass *klass) {
- GPluginLoaderClass *loader_class = GPLUGIN_LOADER_CLASS(klass);
- loader_class->supported_extensions =
- gplugin_python_loader_class_supported_extensions;
- loader_class->query = gplugin_python_loader_query;
- loader_class->load = gplugin_python_loader_load;
- loader_class->unload = gplugin_python_loader_unload;
-/******************************************************************************
- *****************************************************************************/
-gplugin_python_loader_register(GPluginNativePlugin *native) {
- gplugin_python_loader_register_type(G_TYPE_MODULE(native));
- gplugin_python_loader_init_python();
--- a/python/gplugin-python-loader.h Sat Feb 22 03:33:17 2020 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
- * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com>
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, see <http://www.gnu.org/licenses/>.
-#ifndef GPLUGIN_PYTHON_LOADER_H
-#define GPLUGIN_PYTHON_LOADER_H
-#include <gplugin-native.h>
-#define GPLUGIN_PYTHON_TYPE_LOADER (gplugin_python_loader_get_type())
-G_DECLARE_FINAL_TYPE(GPluginPythonLoader, gplugin_python_loader, GPLUGIN_PYTHON, LOADER, GPluginLoader)
-void gplugin_python_loader_register(GPluginNativePlugin *native);
-#endif /* GPLUGIN_PYTHON_LOADER_H */
--- a/python/gplugin-python-plugin.c Sat Feb 22 03:33:17 2020 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,277 +0,0 @@
- * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com>
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, see <http://www.gnu.org/licenses/>.
-#include "gplugin-python-plugin.h"
-/******************************************************************************
- *****************************************************************************/
-struct _GPluginPythonPlugin {
- GPluginPluginInfo *info;
- GPluginPluginState state;
-/******************************************************************************
- *****************************************************************************/
- PROP_FILENAME = N_PROPERTIES,
-static GParamSpec *properties[N_PROPERTIES] = {NULL,};
-/* I hate forward declarations... */
-static void gplugin_python_plugin_iface_init(GPluginPluginInterface *iface);
-G_DEFINE_DYNAMIC_TYPE_EXTENDED(
- G_IMPLEMENT_INTERFACE(GPLUGIN_TYPE_PLUGIN, gplugin_python_plugin_iface_init)
-/******************************************************************************
- * GPluginPlugin Implementation
- *****************************************************************************/
-gplugin_python_plugin_iface_init(G_GNUC_UNUSED GPluginPluginInterface *iface) {
-/******************************************************************************
- *****************************************************************************/
-gplugin_python_plugin_set_module(GPluginPythonPlugin *plugin,
- g_return_if_fail(GPLUGIN_IS_PLUGIN(plugin));
- g_return_if_fail(module);
- Py_CLEAR(plugin->module);
- plugin->module = module;
-gplugin_python_plugin_get_load_func(GPluginPythonPlugin *plugin) {
- g_return_val_if_fail(GPLUGIN_PYTHON_IS_PLUGIN(plugin), NULL);
-gplugin_python_plugin_set_load_func(GPluginPythonPlugin *plugin,
- g_return_if_fail(GPLUGIN_PYTHON_IS_PLUGIN(plugin));
- g_return_if_fail(func != NULL);
- Py_CLEAR(plugin->load);
-gplugin_python_plugin_get_unload_func(GPluginPythonPlugin *plugin) {
- g_return_val_if_fail(GPLUGIN_PYTHON_IS_PLUGIN(plugin), NULL);
-gplugin_python_plugin_set_unload_func(GPluginPythonPlugin *plugin,
- g_return_if_fail(GPLUGIN_PYTHON_IS_PLUGIN(plugin));
- g_return_if_fail(func != NULL);
- Py_CLEAR(plugin->unload);
-/******************************************************************************
- *****************************************************************************/
-gplugin_python_plugin_get_property(GObject *obj, guint param_id, GValue *value,
- GPluginPythonPlugin *plugin = GPLUGIN_PYTHON_PLUGIN(obj);
- g_value_set_pointer(value, plugin->module);
- g_value_set_pointer(value,
- gplugin_python_plugin_get_load_func(plugin));
- g_value_set_pointer(value,
- gplugin_python_plugin_get_unload_func(plugin));
- g_value_set_string(value, plugin->filename);
- g_value_set_object(value, plugin->loader);
- g_value_set_object(value, plugin->info);
- g_value_set_enum(value, plugin->state);
- G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
-gplugin_python_plugin_set_property(GObject *obj, guint param_id,
- const GValue *value, GParamSpec *pspec)
- GPluginPythonPlugin *plugin = GPLUGIN_PYTHON_PLUGIN(obj);
- gplugin_python_plugin_set_module(plugin,
- g_value_get_pointer(value));
- gplugin_python_plugin_set_load_func(plugin,
- g_value_get_pointer(value));
- gplugin_python_plugin_set_unload_func(plugin,
- g_value_get_pointer(value));
- plugin->filename = g_value_dup_string(value);
- plugin->loader = g_value_dup_object(value);
- plugin->info = g_value_dup_object(value);
- plugin->state = g_value_get_enum(value);
- G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
-gplugin_python_plugin_finalize(GObject *obj) {
- GPluginPythonPlugin *plugin = GPLUGIN_PYTHON_PLUGIN(obj);
- Py_CLEAR(plugin->module);
- Py_CLEAR(plugin->load);
- Py_CLEAR(plugin->unload);
- g_clear_pointer(&plugin->filename, g_free);
- g_clear_object(&plugin->loader);
- g_clear_object(&plugin->info);
- G_OBJECT_CLASS(gplugin_python_plugin_parent_class)->finalize(obj);
-gplugin_python_plugin_init(G_GNUC_UNUSED GPluginPythonPlugin *plugin) {
-gplugin_python_plugin_class_finalize(G_GNUC_UNUSED GPluginPythonPluginClass *klass)
-gplugin_python_plugin_class_init(GPluginPythonPluginClass *klass) {
- GObjectClass *obj_class = G_OBJECT_CLASS(klass);
- obj_class->get_property = gplugin_python_plugin_get_property;
- obj_class->set_property = gplugin_python_plugin_set_property;
- obj_class->finalize = gplugin_python_plugin_finalize;
- properties[PROP_MODULE] = g_param_spec_pointer(
- "The python module object",
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY
- properties[PROP_LOAD_FUNC] = g_param_spec_pointer(
- "load-func", "load-func",
- "The python load function",
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY
- properties[PROP_UNLOAD_FUNC] = g_param_spec_pointer(
- "unload-func", "unload-func",
- "The python unload function",
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY
- g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
- /* add our overrides */
- g_object_class_override_property(obj_class, PROP_FILENAME, "filename");
- g_object_class_override_property(obj_class, PROP_LOADER, "loader");
- g_object_class_override_property(obj_class, PROP_INFO, "info");
- g_object_class_override_property(obj_class, PROP_STATE, "state");
-/******************************************************************************
- *****************************************************************************/
-gplugin_python_plugin_register(GPluginNativePlugin *native) {
- gplugin_python_plugin_register_type(G_TYPE_MODULE(native));
--- a/python/gplugin-python-plugin.h Sat Feb 22 03:33:17 2020 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
- * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com>
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, see <http://www.gnu.org/licenses/>.
-#ifndef GPLUGIN_PYTHON_PLUGIN_H
-#define GPLUGIN_PYTHON_PLUGIN_H
-#include <gplugin-native.h>
-#define GPLUGIN_PYTHON_TYPE_PLUGIN (gplugin_python_plugin_get_type())
-G_DECLARE_FINAL_TYPE(GPluginPythonPlugin, gplugin_python_plugin, GPLUGIN_PYTHON, PLUGIN, GObject)
-void gplugin_python_plugin_register(GPluginNativePlugin *native);
-#endif /* GPLUGIN_PYTHON_PLUGIN_H */
--- a/python/gplugin-python-test-pygobject.c Sat Feb 22 03:33:17 2020 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
- * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com>
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, see <http://www.gnu.org/licenses/>.
-main(gint argc, gchar *argv[]) {
- wchar_t *wargv[] = { NULL, NULL };
- /* initialize python */
- if(!Py_IsInitialized())
- Py_InitializeEx(FALSE);
- len = mbstowcs(NULL, argv[0], 0);
- wargv[0] = g_new0(wchar_t, len + 1);
- len = mbstowcs(wargv[0], argv[0], len + 1);
- if(len == (size_t)-1) {
-#if PY_VERSION_HEX < 0x03010300
- PySys_SetArgv(1, wargv);
- PyRun_SimpleString("import sys; sys.path.pop(0)\n");
- PySys_SetArgvEx(1, wargv, 0);
- /* initialize pygobject */
- pygobject_init(3, 0, 0);
--- a/python/gplugin-python-utils.c Sat Feb 22 03:33:17 2020 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,111 +0,0 @@
- * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com>
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, see <http://www.gnu.org/licenses/>.
-#include <gplugin/gplugin.h>
-#include "gplugin-python-utils.h"
-gplugin_python_filename_to_module(const gchar *filename) {
- gchar *e = NULL, *r = NULL;
- g_return_val_if_fail(filename != NULL, NULL);
- /* first make sure we just have a filename */
- base = g_path_get_basename(filename);
- /* now find the last . for the extension */
- e = g_utf8_strrchr(base, g_utf8_strlen(base, -1), g_utf8_get_char("."));
- /* now copy the module name into r */
- r = g_malloc(e - base + 1);
- memcpy(r, base, e - base);
- /* free the basename */
-gplugin_python_add_module_path(const gchar *module_path) {
- PyObject *sys_path = NULL, *path = NULL;
- sys_path = PySys_GetObject("path");
- path = PyUnicode_FromString(module_path);
- if(PySequence_Contains(sys_path, path) == 0) {
- PyList_Insert(sys_path, 0, path);
-gplugin_python_exception_to_gerror(void) {
- PyObject *type = NULL, *value = NULL, *trace = NULL;
- PyObject *type_name = NULL, *value_str = NULL, *obj = NULL;
- PyErr_Fetch(&type, &value, &trace);
- PyErr_NormalizeException(&type, &value, &trace);
- type_name = PyObject_GetAttrString(type, "__name__");
- value_str = PyObject_Str(value);
- /* now decode the utf8 into a string we can use */
- obj = PyUnicode_AsUTF8String(type_name);
- obj = PyUnicode_AsUTF8String(value_str);
- error = g_error_new(GPLUGIN_DOMAIN, 0, "%s: %s",
- PyBytes_AsString(type_name),
- PyBytes_AsString(value_str));
--- a/python/gplugin-python-utils.h Sat Feb 22 03:33:17 2020 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
- * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com>
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, see <http://www.gnu.org/licenses/>.
-#ifndef GPLUGIN_PYTHON_UTILS_H
-#define GPLUGIN_PYTHON_UTILS_H
-#define GPLUGIN_PYTHON_DOMAIN (g_quark_from_static_string("gplugin-python"))
-gchar *gplugin_python_filename_to_module(const gchar *filename);
-gboolean gplugin_python_add_module_path(const gchar *module_path);
-GError *gplugin_python_exception_to_gerror(void);
-#endif /* GPLUGIN_PYTHON_UTILS_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/python/gplugin-python3-core.c Sat Feb 22 03:41:23 2020 -0600
@@ -0,0 +1,75 @@
+ * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com> + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see <http://www.gnu.org/licenses/>. +#include <gplugin-native.h> +#include <glib/gi18n-lib.h> +#include "gplugin-python3-loader.h" +#include "gplugin-python3-plugin.h" +G_MODULE_EXPORT GPluginPluginInfo * +gplugin_query(G_GNUC_UNUSED GError **error) { + const gchar * const authors[] = { + "Gary Kramlich <grim@reaperworld.com>", + return gplugin_plugin_info_new( + "gplugin/python3-loader", + GPLUGIN_NATIVE_PLUGIN_ABI_VERSION, + "name", "Python Plugin Loader", + "version", GPLUGIN_VERSION, + "license-id", "LGPL-2.0-or-later", + "summary", "A plugin that can load python plugins", + "description", "This plugin allows the loading of plugins written in " + "the python programming language.", + "website", GPLUGIN_WEBSITE, +G_MODULE_EXPORT gboolean +gplugin_load(GPluginNativePlugin *plugin, + G_GNUC_UNUSED GError **error) + gplugin_python_plugin_register(plugin); + gplugin_python_loader_register(plugin); + gplugin_manager_register_loader(GPLUGIN_PYTHON_TYPE_LOADER); +G_MODULE_EXPORT gboolean +gplugin_unload(G_GNUC_UNUSED GPluginNativePlugin *plugin, + _("The Python loader can not be unloaded") --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/python/gplugin-python3-loader.c Sat Feb 22 03:41:23 2020 -0600
@@ -0,0 +1,373 @@
+ * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com> + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see <http://www.gnu.org/licenses/>. +#include "gplugin-python3-loader.h" +#include "gplugin-python3-plugin.h" +#include "gplugin-python3-utils.h" +#include <glib/gi18n-lib.h> +struct _GPluginPythonLoader { + PyThreadState *py_thread_state; +G_DEFINE_DYNAMIC_TYPE(GPluginPythonLoader, gplugin_python_loader, GPLUGIN_TYPE_LOADER); +/****************************************************************************** + * GPluginLoader Implementation + *****************************************************************************/ +gplugin_python_loader_class_supported_extensions(G_GNUC_UNUSED GPluginLoaderClass *klass) { + return g_slist_append(NULL, "py"); +gplugin_python_loader_query(GPluginLoader *loader, + G_GNUC_UNUSED GError **error) + GPluginPlugin *plugin = NULL; + PyObject *pyinfo = NULL, *args = NULL; + PyObject *module = NULL, *package_list = NULL, *module_dict = NULL; + PyObject *query = NULL, *load = NULL, *unload = NULL; + PyGILState_STATE state; + gchar *module_name = NULL, *dir_name = NULL; + state = pyg_gil_state_ensure(); + /* create package_list as a tuple to handle 'import foo.bar' */ + package_list = PyTuple_New(0); + /* now figure out the module name from the filename */ + module_name = gplugin_python_filename_to_module(filename); + /* grab the dirname since we need it on sys.path to import the module */ + dir_name = g_path_get_dirname(filename); + gplugin_python_add_module_path(dir_name); + /* import the module */ + module = PyImport_ImportModuleEx(module_name, NULL, NULL, package_list); + g_warning(_("Failed to query %s"), filename); + /* clean some stuff up */ + Py_DECREF(package_list); + pyg_gil_state_release(state); + /* clean some stuff up */ + Py_DECREF(package_list); + /* at this point we have the module, lets find the query, load, and unload + module_dict = PyModule_GetDict(module); + query = PyDict_GetItemString(module_dict, "gplugin_query"); + g_warning(_("Failed to find the gplugin_query function in %s"), + pyg_gil_state_release(state); + if(!PyCallable_Check(query)) { + g_warning(_("Found gplugin_query in %s but it is not a " + pyg_gil_state_release(state); + load = PyDict_GetItemString(module_dict, "gplugin_load"); + g_warning(_("Failed to find the gplugin_load function in %s"), + pyg_gil_state_release(state); + if(!PyCallable_Check(load)) { + g_warning(_("Found gplugin_load in %s but it is not a " + pyg_gil_state_release(state); + unload = PyDict_GetItemString(module_dict, "gplugin_unload"); + g_warning(_("Failed to find the gplugin_unload function in %s"), + pyg_gil_state_release(state); + if(!PyCallable_Check(unload)) { + g_warning(_("Found gplugin_unload in %s but it is not a " + pyg_gil_state_release(state); + /* now that we have everything, call the query method and get the plugin's + pyinfo = PyObject_Call(query, args, NULL); + info = pygobject_get(pyinfo); + /* now that we have everything, create the plugin */ + plugin = g_object_new(GPLUGIN_PYTHON_TYPE_PLUGIN, + pyg_gil_state_release(state); +gplugin_python_loader_load(G_GNUC_UNUSED GPluginLoader *loader, + PyObject *load = NULL, *pyplugin = NULL, *result = NULL; + g_object_get(G_OBJECT(plugin), "load-func", &load, NULL); + pyplugin = pygobject_new(G_OBJECT(plugin)); + result = PyObject_CallFunctionObjArgs(load, pyplugin, NULL); + if (PyErr_Occurred()) { + *error = gplugin_python_exception_to_gerror(); + ret = PyObject_IsTrue(result); + g_set_error_literal(error, GPLUGIN_DOMAIN, 0, + _("Failed to load plugin")); +gplugin_python_loader_unload(G_GNUC_UNUSED GPluginLoader *loader, + PyObject *unload = NULL, *pyplugin = NULL, *result = NULL; + g_object_get(G_OBJECT(plugin), "unload-func", &unload, NULL); + pyplugin = pygobject_new(G_OBJECT(plugin)); + result = PyObject_CallFunctionObjArgs(unload, pyplugin, NULL); + ret = PyObject_IsTrue(result); + g_set_error_literal(error, GPLUGIN_DOMAIN, 0, + _("Failed to unload plugin")); +/****************************************************************************** + *****************************************************************************/ +gplugin_python_loader_init_pygobject(void) { + pygobject_init(3, 0, 0); + PyObject *type = NULL, *value = NULL, *tb = NULL, *obj = NULL; + PyErr_Fetch(&type, &value, &tb); + obj = PyUnicode_AsUTF8String(value); + g_warning("Failed to initialize PyGObject : %s", PyBytes_AsString(obj)); + /* disable g_log redirections */ + pyg_disable_warning_redirections(); +gplugin_python_loader_init_gettext(void) { + PyObject *module_dict = NULL, *install = NULL; + PyObject *gettext = NULL, *result = NULL; + gettext = PyImport_ImportModule("gettext"); + g_warning("Failed to import gettext"); + module_dict = PyModule_GetDict(gettext); + install = PyDict_GetItemString(module_dict, "install"); + result = PyObject_CallFunction(install, "ss", GETTEXT_PACKAGE, LOCALEDIR); +gplugin_python_loader_init_python(void) { + wchar_t *argv[] = { NULL, NULL }; + /* Initializes Python */ + if(!Py_IsInitialized()) + Py_InitializeEx(FALSE); + argv[0] = Py_DecodeLocale(g_get_prgname(), NULL); + g_warning("Could not convert program name to wchar_t string."); + /* setup sys.path according to + * https://docs.python.org/3/c-api/init.html#PySys_SetArgvEx + PySys_SetArgvEx(1, argv, 0); + PyMem_RawFree(argv[0]); + /* initialize pygobject */ + if(gplugin_python_loader_init_pygobject()) { + if(gplugin_python_loader_init_gettext()) { +/****************************************************************************** + *****************************************************************************/ +gplugin_python_loader_init(G_GNUC_UNUSED GPluginPythonLoader *loader) { +gplugin_python_loader_class_finalize(G_GNUC_UNUSED GPluginPythonLoaderClass *klass) +gplugin_python_loader_class_init(GPluginPythonLoaderClass *klass) { + GPluginLoaderClass *loader_class = GPLUGIN_LOADER_CLASS(klass); + loader_class->supported_extensions = + gplugin_python_loader_class_supported_extensions; + loader_class->query = gplugin_python_loader_query; + loader_class->load = gplugin_python_loader_load; + loader_class->unload = gplugin_python_loader_unload; +/****************************************************************************** + *****************************************************************************/ +gplugin_python_loader_register(GPluginNativePlugin *native) { + gplugin_python_loader_register_type(G_TYPE_MODULE(native)); + gplugin_python_loader_init_python(); --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/python/gplugin-python3-loader.h Sat Feb 22 03:41:23 2020 -0600
@@ -0,0 +1,33 @@
+ * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com> + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see <http://www.gnu.org/licenses/>. +#ifndef GPLUGIN_PYTHON_LOADER_H +#define GPLUGIN_PYTHON_LOADER_H +#include <gplugin-native.h> +#define GPLUGIN_PYTHON_TYPE_LOADER (gplugin_python_loader_get_type()) +G_DECLARE_FINAL_TYPE(GPluginPythonLoader, gplugin_python_loader, GPLUGIN_PYTHON, LOADER, GPluginLoader) +void gplugin_python_loader_register(GPluginNativePlugin *native); +#endif /* GPLUGIN_PYTHON_LOADER_H */ --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/python/gplugin-python3-plugin.c Sat Feb 22 03:41:23 2020 -0600
@@ -0,0 +1,277 @@
+ * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com> + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see <http://www.gnu.org/licenses/>. +#include "gplugin-python3-plugin.h" +/****************************************************************************** + *****************************************************************************/ +struct _GPluginPythonPlugin { + GPluginPluginInfo *info; + GPluginPluginState state; +/****************************************************************************** + *****************************************************************************/ + PROP_FILENAME = N_PROPERTIES, +static GParamSpec *properties[N_PROPERTIES] = {NULL,}; +/* I hate forward declarations... */ +static void gplugin_python_plugin_iface_init(GPluginPluginInterface *iface); +G_DEFINE_DYNAMIC_TYPE_EXTENDED( + G_IMPLEMENT_INTERFACE(GPLUGIN_TYPE_PLUGIN, gplugin_python_plugin_iface_init) +/****************************************************************************** + * GPluginPlugin Implementation + *****************************************************************************/ +gplugin_python_plugin_iface_init(G_GNUC_UNUSED GPluginPluginInterface *iface) { +/****************************************************************************** + *****************************************************************************/ +gplugin_python_plugin_set_module(GPluginPythonPlugin *plugin, + g_return_if_fail(GPLUGIN_IS_PLUGIN(plugin)); + g_return_if_fail(module); + Py_CLEAR(plugin->module); + plugin->module = module; +gplugin_python_plugin_get_load_func(GPluginPythonPlugin *plugin) { + g_return_val_if_fail(GPLUGIN_PYTHON_IS_PLUGIN(plugin), NULL); +gplugin_python_plugin_set_load_func(GPluginPythonPlugin *plugin, + g_return_if_fail(GPLUGIN_PYTHON_IS_PLUGIN(plugin)); + g_return_if_fail(func != NULL); + Py_CLEAR(plugin->load); +gplugin_python_plugin_get_unload_func(GPluginPythonPlugin *plugin) { + g_return_val_if_fail(GPLUGIN_PYTHON_IS_PLUGIN(plugin), NULL); +gplugin_python_plugin_set_unload_func(GPluginPythonPlugin *plugin, + g_return_if_fail(GPLUGIN_PYTHON_IS_PLUGIN(plugin)); + g_return_if_fail(func != NULL); + Py_CLEAR(plugin->unload); +/****************************************************************************** + *****************************************************************************/ +gplugin_python_plugin_get_property(GObject *obj, guint param_id, GValue *value, + GPluginPythonPlugin *plugin = GPLUGIN_PYTHON_PLUGIN(obj); + g_value_set_pointer(value, plugin->module); + g_value_set_pointer(value, + gplugin_python_plugin_get_load_func(plugin)); + g_value_set_pointer(value, + gplugin_python_plugin_get_unload_func(plugin)); + g_value_set_string(value, plugin->filename); + g_value_set_object(value, plugin->loader); + g_value_set_object(value, plugin->info); + g_value_set_enum(value, plugin->state); + G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); +gplugin_python_plugin_set_property(GObject *obj, guint param_id, + const GValue *value, GParamSpec *pspec) + GPluginPythonPlugin *plugin = GPLUGIN_PYTHON_PLUGIN(obj); + gplugin_python_plugin_set_module(plugin, + g_value_get_pointer(value)); + gplugin_python_plugin_set_load_func(plugin, + g_value_get_pointer(value)); + gplugin_python_plugin_set_unload_func(plugin, + g_value_get_pointer(value)); + plugin->filename = g_value_dup_string(value); + plugin->loader = g_value_dup_object(value); + plugin->info = g_value_dup_object(value); + plugin->state = g_value_get_enum(value); + G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); +gplugin_python_plugin_finalize(GObject *obj) { + GPluginPythonPlugin *plugin = GPLUGIN_PYTHON_PLUGIN(obj); + Py_CLEAR(plugin->module); + Py_CLEAR(plugin->load); + Py_CLEAR(plugin->unload); + g_clear_pointer(&plugin->filename, g_free); + g_clear_object(&plugin->loader); + g_clear_object(&plugin->info); + G_OBJECT_CLASS(gplugin_python_plugin_parent_class)->finalize(obj); +gplugin_python_plugin_init(G_GNUC_UNUSED GPluginPythonPlugin *plugin) { +gplugin_python_plugin_class_finalize(G_GNUC_UNUSED GPluginPythonPluginClass *klass) +gplugin_python_plugin_class_init(GPluginPythonPluginClass *klass) { + GObjectClass *obj_class = G_OBJECT_CLASS(klass); + obj_class->get_property = gplugin_python_plugin_get_property; + obj_class->set_property = gplugin_python_plugin_set_property; + obj_class->finalize = gplugin_python_plugin_finalize; + properties[PROP_MODULE] = g_param_spec_pointer( + "The python module object", + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY + properties[PROP_LOAD_FUNC] = g_param_spec_pointer( + "load-func", "load-func", + "The python load function", + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY + properties[PROP_UNLOAD_FUNC] = g_param_spec_pointer( + "unload-func", "unload-func", + "The python unload function", + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY + g_object_class_install_properties(obj_class, N_PROPERTIES, properties); + /* add our overrides */ + g_object_class_override_property(obj_class, PROP_FILENAME, "filename"); + g_object_class_override_property(obj_class, PROP_LOADER, "loader"); + g_object_class_override_property(obj_class, PROP_INFO, "info"); + g_object_class_override_property(obj_class, PROP_STATE, "state"); +/****************************************************************************** + *****************************************************************************/ +gplugin_python_plugin_register(GPluginNativePlugin *native) { + gplugin_python_plugin_register_type(G_TYPE_MODULE(native)); --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/python/gplugin-python3-plugin.h Sat Feb 22 03:41:23 2020 -0600
@@ -0,0 +1,33 @@
+ * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com> + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see <http://www.gnu.org/licenses/>. +#ifndef GPLUGIN_PYTHON_PLUGIN_H +#define GPLUGIN_PYTHON_PLUGIN_H +#include <gplugin-native.h> +#define GPLUGIN_PYTHON_TYPE_PLUGIN (gplugin_python_plugin_get_type()) +G_DECLARE_FINAL_TYPE(GPluginPythonPlugin, gplugin_python_plugin, GPLUGIN_PYTHON, PLUGIN, GObject) +void gplugin_python_plugin_register(GPluginNativePlugin *native); +#endif /* GPLUGIN_PYTHON_PLUGIN_H */ --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/python/gplugin-python3-test-pygobject.c Sat Feb 22 03:41:23 2020 -0600
@@ -0,0 +1,65 @@
+ * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com> + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see <http://www.gnu.org/licenses/>. +main(gint argc, gchar *argv[]) { + wchar_t *wargv[] = { NULL, NULL }; + /* initialize python */ + if(!Py_IsInitialized()) + Py_InitializeEx(FALSE); + len = mbstowcs(NULL, argv[0], 0); + wargv[0] = g_new0(wchar_t, len + 1); + len = mbstowcs(wargv[0], argv[0], len + 1); + if(len == (size_t)-1) { +#if PY_VERSION_HEX < 0x03010300 + PySys_SetArgv(1, wargv); + PyRun_SimpleString("import sys; sys.path.pop(0)\n"); + PySys_SetArgvEx(1, wargv, 0); + /* initialize pygobject */ + pygobject_init(3, 0, 0); --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/python/gplugin-python3-utils.c Sat Feb 22 03:41:23 2020 -0600
@@ -0,0 +1,111 @@
+ * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com> + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see <http://www.gnu.org/licenses/>. +#include <gplugin/gplugin.h> +#include "gplugin-python3-utils.h" +gplugin_python_filename_to_module(const gchar *filename) { + gchar *e = NULL, *r = NULL; + g_return_val_if_fail(filename != NULL, NULL); + /* first make sure we just have a filename */ + base = g_path_get_basename(filename); + /* now find the last . for the extension */ + e = g_utf8_strrchr(base, g_utf8_strlen(base, -1), g_utf8_get_char(".")); + /* now copy the module name into r */ + r = g_malloc(e - base + 1); + memcpy(r, base, e - base); + /* free the basename */ +gplugin_python_add_module_path(const gchar *module_path) { + PyObject *sys_path = NULL, *path = NULL; + sys_path = PySys_GetObject("path"); + path = PyUnicode_FromString(module_path); + if(PySequence_Contains(sys_path, path) == 0) { + PyList_Insert(sys_path, 0, path); +gplugin_python_exception_to_gerror(void) { + PyObject *type = NULL, *value = NULL, *trace = NULL; + PyObject *type_name = NULL, *value_str = NULL, *obj = NULL; + PyErr_Fetch(&type, &value, &trace); + PyErr_NormalizeException(&type, &value, &trace); + type_name = PyObject_GetAttrString(type, "__name__"); + value_str = PyObject_Str(value); + /* now decode the utf8 into a string we can use */ + obj = PyUnicode_AsUTF8String(type_name); + obj = PyUnicode_AsUTF8String(value_str); + error = g_error_new(GPLUGIN_DOMAIN, 0, "%s: %s", + PyBytes_AsString(type_name), + PyBytes_AsString(value_str)); --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/python/gplugin-python3-utils.h Sat Feb 22 03:41:23 2020 -0600
@@ -0,0 +1,35 @@
+ * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com> + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see <http://www.gnu.org/licenses/>. +#ifndef GPLUGIN_PYTHON_UTILS_H +#define GPLUGIN_PYTHON_UTILS_H +#define GPLUGIN_PYTHON_DOMAIN (g_quark_from_static_string("gplugin-python")) +gchar *gplugin_python_filename_to_module(const gchar *filename); +gboolean gplugin_python_add_module_path(const gchar *module_path); +GError *gplugin_python_exception_to_gerror(void); +#endif /* GPLUGIN_PYTHON_UTILS_H */ --- a/python/meson.build Sat Feb 22 03:33:17 2020 -0600
+++ b/python/meson.build Sat Feb 22 03:41:23 2020 -0600
@@ -3,17 +3,17 @@
error('Python plugin requires GObject Introspection.')
- GPLUGIN_PYTHON_SOURCES = [
- 'gplugin-python-core.c',
- 'gplugin-python-loader.c',
- 'gplugin-python-plugin.c',
- 'gplugin-python-utils.c',
+ GPLUGIN_PYTHON3_SOURCES = [ + 'gplugin-python3-core.c', + 'gplugin-python3-loader.c', + 'gplugin-python3-plugin.c', + 'gplugin-python3-utils.c', - GPLUGIN_PYTHON_HEADERS = [
- 'gplugin-python-loader.h',
- 'gplugin-python-plugin.h',
- 'gplugin-python-utils.h',
+ GPLUGIN_PYTHON3_HEADERS = [ + 'gplugin-python3-loader.h', + 'gplugin-python3-plugin.h', + 'gplugin-python3-utils.h', PYTHON3 = dependency('python3-embed', version: '>=3.5.0', required: false)
@@ -24,37 +24,37 @@
PYGOBJECT = dependency('pygobject-3.0', version: '>=3.0.0')
# Compile and run our python-gi test program
- python_gi_test = compiler.run(files('gplugin-python-test-pygobject.c'),
+ python3_gi_test = compiler.run(files('gplugin-python3-test-pygobject.c'), dependencies : [GLIB, PYTHON3, PYGOBJECT],
- if not python_gi_test.compiled() or python_gi_test.returncode() != 0
- error('pygobject does not work with python3')
+ if not python3_gi_test.compiled() or python3_gi_test.returncode() != 0 + error('pygobject does not work with Python3') - gplugin_python_inc = include_directories('.')
- gplugin_python = shared_library('gplugin-python3',
- GPLUGIN_PYTHON_SOURCES,
- GPLUGIN_PYTHON_HEADERS,
+ gplugin_python3_inc = include_directories('.') + gplugin_python3 = shared_library('gplugin-python3', + GPLUGIN_PYTHON3_SOURCES, + GPLUGIN_PYTHON3_HEADERS, dependencies : [PYTHON3, PYGOBJECT, gplugin_dep],
install_dir : join_paths(get_option('libdir'), 'gplugin')
- gplugin_python_dep = declare_dependency(
- include_directories : gplugin_python_inc,
- link_with : gplugin_python,
+ gplugin_python3_dep = declare_dependency( + include_directories : gplugin_python3_inc, + link_with : gplugin_python3, - gplugin_python_static = static_library('gplugin-python-static',
- GPLUGIN_PYTHON_SOURCES,
- GPLUGIN_PYTHON_HEADERS,
+ gplugin_python3_static = static_library('gplugin-python3-static', + GPLUGIN_PYTHON3_SOURCES, + GPLUGIN_PYTHON3_HEADERS, dependencies : [PYTHON3, PYGOBJECT, gplugin_dep],
- gplugin_python_static_dep = declare_dependency(
- include_directories : gplugin_python_inc,
- link_with : gplugin_python_static,
+ gplugin_python3_static_dep = declare_dependency( + include_directories : gplugin_python3_inc, + link_with : gplugin_python3_static,
--- a/python/tests/meson.build Sat Feb 22 03:33:17 2020 -0600
+++ b/python/tests/meson.build Sat Feb 22 03:41:23 2020 -0600
@@ -16,7 +16,7 @@
include_directories : include_directories('.'),
link_with : [gplugin_loader_tests],
dependencies : [GLIB, GOBJECT, PYTHON3, PYGOBJECT,
- gplugin_python_static_dep])
+ gplugin_python3_static_dep]) --- a/python/tests/test-python3-utils.c Sat Feb 22 03:33:17 2020 -0600
+++ b/python/tests/test-python3-utils.c Sat Feb 22 03:41:23 2020 -0600
@@ -17,7 +17,7 @@
-#include "gplugin-python-utils.h"
+#include "gplugin-python3-utils.h"