about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorj.r <j.r@jugendhacker.de>2022-02-18 18:50:02 +0100
committerj.r <j.r@jugendhacker.de>2022-02-18 19:45:31 +0100
commit5676159aa52a734a34bf231b400ae13860e1012d (patch)
tree38da66ce956e8b3446ded0198f00441f22dacb40 /src
parent57fb10f0bf11351a5c5490742e61b29c36d95d38 (diff)
downloadprofani-tty-5676159aa52a734a34bf231b400ae13860e1012d.tar.gz
Fix python executed during configure
Previously it relied on AX_PYTHON_DEVEL, which in turn executes
python-config to get the build flags. However this does not work while
cross compiling because we can't execute the python-config build for the
target platform. To circumvent this problem the python build flags are
now queried via pkgconfig, which has the drawback of not having some
extra build flags, but they do not seem to be needed.

I tested this patch with the termux build system and it build without
their existing hack of injecting python after the configure step. I also
tested non cross compile build on Arch Linux and it also still works.

Fixes #851
Diffstat (limited to 'src')
-rw-r--r--src/plugins/python_api.c8
-rw-r--r--src/plugins/python_plugins.c2
2 files changed, 5 insertions, 5 deletions
diff --git a/src/plugins/python_api.c b/src/plugins/python_api.c
index 90e33579..0b91cf70 100644
--- a/src/plugins/python_api.c
+++ b/src/plugins/python_api.c
@@ -1575,7 +1575,7 @@ static PyMethodDef apiMethods[] = {
     { NULL, NULL, 0, NULL }
 };
 
-#if PY_MAJOR_VERSION >= 3
+#ifdef PY_IS_PYTHON3
 static struct PyModuleDef profModule = {
     PyModuleDef_HEAD_INIT,
     "prof",
@@ -1588,7 +1588,7 @@ static struct PyModuleDef profModule = {
 PyMODINIT_FUNC
 python_api_init(void)
 {
-#if PY_MAJOR_VERSION >= 3
+#ifdef PY_IS_PYTHON3
     PyObject* result = PyModule_Create(&profModule);
     if (!result) {
         log_debug("Failed to initialise prof module");
@@ -1604,7 +1604,7 @@ python_api_init(void)
 void
 python_init_prof(void)
 {
-#if PY_MAJOR_VERSION >= 3
+#ifdef PY_IS_PYTHON3
     PyImport_AppendInittab("prof", python_api_init);
     Py_Initialize();
     PyEval_InitThreads();
@@ -1640,7 +1640,7 @@ python_str_or_unicode_to_string(void* obj)
         return NULL;
     }
 
-#if PY_MAJOR_VERSION >= 3
+#ifdef PY_IS_PYTHON3
     if (PyUnicode_Check(pyobj)) {
         PyObject* utf8_str = PyUnicode_AsUTF8String(pyobj);
         char* result = strdup(PyBytes_AS_STRING(utf8_str));
diff --git a/src/plugins/python_plugins.c b/src/plugins/python_plugins.c
index 94c77e99..c32d177c 100644
--- a/src/plugins/python_plugins.c
+++ b/src/plugins/python_plugins.c
@@ -908,7 +908,7 @@ _handle_string_or_none_result(ProfPlugin* plugin, PyObject* result, char* hook)
         _python_undefined_error(plugin, hook, "string, unicode or None");
         return NULL;
     }
-#if PY_MAJOR_VERSION >= 3
+#ifdef PY_IS_PYTHON3
     if (result != Py_None && !PyUnicode_Check(result) && !PyBytes_Check(result)) {
         allow_python_threads();
         _python_type_error(plugin, hook, "string, unicode or None");