Message ID | CAM=7fbcPzoWjyzWUDt9hR1X7biFbhqMtRC2revfLQHfTc+Herw@mail.gmail.com |
---|---|
State | Not Applicable |
Headers | show |
Series | Python import error for PyInit_wpaspy | expand |
On Tue, Mar 31, 2020 at 04:22:01PM -0500, Jared Bents wrote: > I'm attempting to cross compile wpaspy with Buildroot Do you have a specific reason for using the wpaspy.c version instead of the native wpaspy.py? > Has anyone had success cross compiling wpaspy with python 3 support? I > had run into a couple prior problems when using python 3 but sorted > those out and once I get everything working, I plan on upstreaming > them. I've included the diffs below for reference. I have not use wpaspy.c in years since the native implementation in wpaspy.py covers all the functionality that I've needed. wpaspy.c has not been modified in seven years and unless there is a specific need for it, the most practical upstream change might be to simply delete that older implementation and leave the maintained wpaspy.py version as the only option.
Hi Jouni, On Wed, Apr 1, 2020 at 5:47 AM Jouni Malinen <j@w1.fi> wrote: > > On Tue, Mar 31, 2020 at 04:22:01PM -0500, Jared Bents wrote: > > I'm attempting to cross compile wpaspy with Buildroot > > Do you have a specific reason for using the wpaspy.c version instead of > the native wpaspy.py? No specific reason, I did not know it was an option to use just the wpaspy.py instead of including the wpaspy.c. I was attempting to use wpaspy.c because that is what the setup.py in the 2.9 tag on hostap is using. So I will change my focus to having the wpaspy.py get included instead of the build of wpaspy.c > > > Has anyone had success cross compiling wpaspy with python 3 support? I > > had run into a couple prior problems when using python 3 but sorted > > those out and once I get everything working, I plan on upstreaming > > them. I've included the diffs below for reference. > > I have not use wpaspy.c in years since the native implementation in > wpaspy.py covers all the functionality that I've needed. wpaspy.c has > not been modified in seven years and unless there is a specific need for > it, the most practical upstream change might be to simply delete that > older implementation and leave the maintained wpaspy.py version as the > only option. > > -- > Jouni Malinen PGP id EFC895FA Thank you, Jared
diff --git a/wpaspy/wpaspy.c b/wpaspy/wpaspy.c index 278089b48..8a7c1fe1a 100644 --- a/wpaspy/wpaspy.c +++ b/wpaspy/wpaspy.c @@ -44,8 +44,8 @@ static void wpaspy_close(struct wpaspy_obj *self) >......>.......self->ctrl = NULL; >......} . ->......if (self->ob_type) ->......>.......self->ob_type->tp_free((PyObject *) self); +>......if (Py_TYPE(self)) +>......>.......Py_TYPE(self)->tp_free((PyObject *) self); } . . @@ -198,12 +198,22 @@ static PyMethodDef module_methods[] = { }; . . +static struct PyModuleDef wpaspy = +{ + PyModuleDef_HEAD_INIT, + "wpaspy", + "", + -1, + module_methods +}; + + PyMODINIT_FUNC initwpaspy(void) { >......PyObject *mod; . >......PyType_Ready(&wpaspy_ctrl); ->......mod = Py_InitModule("wpaspy", module_methods); +>......mod = PyModule_Create(&wpaspy); >......wpaspy_error = PyErr_NewException("wpaspy.error", NULL, NULL); . >......Py_INCREF(&wpaspy_ctrl);
Hi all, I'm attempting to cross compile wpaspy with Buildroot and when I attempt to import it on the system I compiled it for, I get the following error # python3 Python 3.8.1 (default, Mar 30 2020, 09:50:30) [GCC 8.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import wpaspy Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: dynamic module does not define module export function () From initial searches on the internet, I thought I was possibly accidentally using python 2 instead of python 3 during the compile step which would cause the error. However, I looked at my build output and added a python version print to the setup.py and both checked out. Part of the build output showing that python 3.8.1 is used to build PYTHONPATH="/accts/jmbents/rclinux/target_build/apm86290_common_platform_debug_defconfig/target/usr/lib/python3.8/" PYTHONNOUSERSITE=1 _PYTHON_SYSCONFIGDATA_NAME="_sysconfigdata__linux_powerpc-linux-gnu" _python_sysroot=/accts/jmbents/rclinux/target_build/apm86290_common_platform_debug_defconfig/host/powerpc-buildroot-linux-gnu/sysroot _python_prefix=/usr _python_exec_prefix=/usr /accts/jmbents/rclinux/target_build/apm86290_common_platform_debug_defconfig/host/bin/python setup.py build --executable=/usr/bin/python ) Python version3.8.1 (default, Mar 30 2020, 09:47:30). [GCC 7.4.0] running build running build_ext Below is my verification of the symlinks provided by Buildroot jmbents@gravy:~/rclinux/target_build/apm86290_common_platform_debug_defconfig$ ls -l /accts/jmbents/rclinux/target_build/apm86290_common_platform_debug_defconfig/host/bin/python lrwxrwxrwx 1 jmbents genusers 7 Mar 30 09:47 /accts/jmbents/rclinux/target_build/apm86290_common_platform_debug_defconfig/host/bin/python -> python3 jmbents@gravy:~/rclinux/target_build/apm86290_common_platform_debug_defconfig$ ls -l /accts/jmbents/rclinux/target_build/apm86290_common_platform_debug_defconfig/host/bin/python3 lrwxrwxrwx 1 jmbents genusers 9 Mar 30 09:47 /accts/jmbents/rclinux/target_build/apm86290_common_platform_debug_defconfig/host/bin/python3 -> python3.8 Has anyone had success cross compiling wpaspy with python 3 support? I had run into a couple prior problems when using python 3 but sorted those out and once I get everything working, I plan on upstreaming them. I've included the diffs below for reference. Thank you, Jared