jnohlgard / python-v4l2capture

Python extension to capture video with video4linux2 (fork of https://launchpad.net/python-v4l2-capture)
133 stars 83 forks source link

Python 3 support #5

Open derpston opened 10 years ago

derpston commented 10 years ago

This module won't build under python 3:

v4l2capture.c: In function ‘Video_device_dealloc’:
v4l2capture.c:116:7: error: ‘Video_device’ has no member named ‘ob_type’

If I attempt to work around that my hackily commenting it out, the module builds but can't be imported:

ImportError: ./v4l2capture.so: undefined symbol: PyString_FromStringAndSize

That can be fixed by using PyBytes* instead of PyString*, but then:

ImportError: ./v4l2capture.so: undefined symbol: PyInt_FromLong

So I try to change that to PyLong_FromLong as suggested here and here

After fixing that, the next problem is:

ImportError: ./v4l2capture.so: undefined symbol: Py_InitModule3

According to here I should change that to InitModule, not InitModule3 or 4. But:

ImportError: ./v4l2capture.so: undefined symbol: Py_InitModule

So, following a suggestion here to link with --export-dynamic, I tried modifying:

gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro build/temp.linux-armv6l-3.2/v4l2capture.o -lv4l2 -o build/lib.linux-armv6l-3.2/v4l2capture.cpython-32mu.so

to

gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,--export-dynamic -Wl,-z,relro build/temp.linux-armv6l-3.2/v4l2capture.o -lv4l2 -o build/lib.linux-armv6l-3.2/v4l2capture.cpython-32mu.so

but the error remains the same:

ImportError: ./v4l2capture.so: undefined symbol: Py_InitModule

At this point, I reached the limit of my ability to hack around with this, and I need an adult. Any ideas for what might be needed to make this module compatible with python 3?

jnohlgard commented 10 years ago

I don't really have any time to spend on this project for the foreseeable future, so I will not be able to assist with this problem. If you solve the problems however, I would be happy to accept pull requests for it.

derpston commented 10 years ago

py3k support is on the way thanks to @rmca: https://github.com/rmca/python-v4l2capture/tree/py3k