Hi guys,
I'm lost in trying to fix the Edgar module to run again in E. Since some
months the python import machinery does not work anymore and the edgar
module is not able anymore to import the python efl bindings.

Nothing has changed in Edgar nor in python-efl and I'm able to correctly
use the machinery in a simple test app (attached), it just does not work
when used inside an E module. I suspect something related to the new meson
build, but not sure at all.

The simple test attached can be built as:
gcc -o test_py test_py.c `python-config --cflags --libs --embed`
`pkg-config --libs --cflags efl-ui`
when run it print OK, that means the python-efl module has been found and
linked. While the same code in edgar fails on the import_efl__eo() call.
Note the test also need the attached .h file to build

To build/run this simple code of course python-efl must be installed
https://phab.enlightenment.org/w/projects/python_bindings_for_efl/

The edgar module instead is documented here:
https://phab.enlightenment.org/w/emodules/edgar/

Any help/ideas would be appreciated as I really don't have any idea atm

The same issue has been recently raised also on the e-user mailing list

Thanks
DaveMDS
/* Generated by Cython 0.29.14 */

#ifndef __PYX_HAVE_API__efl__eo
#define __PYX_HAVE_API__efl__eo
#ifdef __MINGW64__
#define MS_WIN64
#endif
#include "Python.h"

static PyObject *(*__pyx_api_f_3efl_2eo_object_from_instance)(Eo *) = 0;
#define object_from_instance __pyx_api_f_3efl_2eo_object_from_instance
static Eo *(*__pyx_api_f_3efl_2eo_instance_from_object)(PyObject *) = 0;
#define instance_from_object __pyx_api_f_3efl_2eo_instance_from_object
#if !defined(__Pyx_PyIdentifier_FromString)
#if PY_MAJOR_VERSION < 3
  #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
#else
  #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
#endif
#endif

#ifndef __PYX_HAVE_RT_ImportFunction
#define __PYX_HAVE_RT_ImportFunction
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
    PyObject *d = 0;
    PyObject *cobj = 0;
    union {
        void (*fp)(void);
        void *p;
    } tmp;
    d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
    if (!d)
        goto bad;
    cobj = PyDict_GetItemString(d, funcname);
    if (!cobj) {
        PyErr_Format(PyExc_ImportError,
            "%.200s does not export expected C function %.200s",
                PyModule_GetName(module), funcname);
        goto bad;
    }
#if PY_VERSION_HEX >= 0x02070000
    if (!PyCapsule_IsValid(cobj, sig)) {
        PyErr_Format(PyExc_TypeError,
            "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
        goto bad;
    }
    tmp.p = PyCapsule_GetPointer(cobj, sig);
#else
    {const char *desc, *s1, *s2;
    desc = (const char *)PyCObject_GetDesc(cobj);
    if (!desc)
        goto bad;
    s1 = desc; s2 = sig;
    while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
    if (*s1 != *s2) {
        PyErr_Format(PyExc_TypeError,
            "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), funcname, sig, desc);
        goto bad;
    }
    tmp.p = PyCObject_AsVoidPtr(cobj);}
#endif
    *f = tmp.fp;
    if (!(*f))
        goto bad;
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(d);
    return -1;
}
#endif


static int import_efl__eo(void) {
  PyObject *module = 0;
  module = PyImport_ImportModule("efl.eo");
  if (!module) goto bad;
  if (__Pyx_ImportFunction(module, "object_from_instance", (void (**)(void))&__pyx_api_f_3efl_2eo_object_from_instance, "PyObject *(Eo *)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "instance_from_object", (void (**)(void))&__pyx_api_f_3efl_2eo_instance_from_object, "Eo *(PyObject *)") < 0) goto bad;
  Py_DECREF(module); module = 0;
  return 0;
  bad:
  Py_XDECREF(module);
  return -1;
}

#endif /* !__PYX_HAVE_API__efl__eo */
// gcc -o test_py test_py.c `python-config --cflags --libs --embed` `pkg-config --libs --cflags efl-ui` &&  ./test_py

#include <Python.h>
#include <stdio.h>

#include <Efl_Ui.h>
#include "efl.eo_api.h"



int main() {
   printf("Hello, World! \n");

   Py_Initialize();

   if (import_efl__eo() != 0)
   {
      printf("ERROR: Cannot import python-efl \n");
      return 1;
   }
   else
   {
      printf("OK \n");   
   }

   Py_Finalize();
   printf("DONE \n");
   return 0;
}
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to