Re: Python extension using a C library with one 'hello' function

2014-11-04 Thread Jason Swails
On Tue, 2014-11-04 at 23:03 +0630, Veek M wrote: > okay got it working - thanks Jason! The 3.2 docs are slightly different. What did you need to do to get it working? -- https://mail.python.org/mailman/listinfo/python-list

Re: Python extension using a C library with one 'hello' function

2014-11-04 Thread Veek M
okay got it working - thanks Jason! The 3.2 docs are slightly different. -- https://mail.python.org/mailman/listinfo/python-list

Re: Python extension using a C library with one 'hello' function

2014-11-04 Thread Jason Swails
On Tue, Nov 4, 2014 at 11:09 AM, Veek M wrote: > static PyMethodDef hellomethods[] = { > {"hello", py_hello, METH_VARARGS, py_hello_doc}, > {NULL, NULL, 0, NULL}, > }; > > It's basically the METH_VARARGS field that's giving the problem. Switching > it to NULL gives, > SystemError: Bad cal

Re: Python extension using a C library with one 'hello' function

2014-11-04 Thread Veek M
static PyMethodDef hellomethods[] = { {"hello", py_hello, METH_VARARGS, py_hello_doc}, {NULL, NULL, 0, NULL}, }; It's basically the METH_VARARGS field that's giving the problem. Switching it to NULL gives, SystemError: Bad call flags in PyCFunction_Call. METH_OLDARGS is no longer suppor

Re: Python extension using a C library with one 'hello' function

2014-11-04 Thread Veek M
Jason Swails wrote: > What operating system are you running this on? It works fine for me on > Linux: Wheezy Debian, Linux deathstar 3.2.0-4-amd64 #1 SMP Debian 3.2.60-1+deb7u3 x86_64 GNU/Linux gcc (Debian 4.7.2-5) 4.7.2 Python 3.2.3 I ran it through gdb - not very useful: (gdb) bt #0 0x00

Re: Python extension using a C library with one 'hello' function

2014-11-04 Thread Jason Swails
On Tue, 2014-11-04 at 21:45 +0630, Veek M wrote: > Jason Swails wrote: > > > I've submitted a PR to your github repo showing you the changes > > necessary to get your module working on my computer. > > Segfaults :p which is an improvement :) What operating system are you running this on? It wor

Re: Python extension using a C library with one 'hello' function

2014-11-04 Thread Veek M
Søren wrote: > import ctypes Hi, yeah i kind of liked it - still reading the docs though, Beazley has the Python.h solution so I though I'd try that first. -- https://mail.python.org/mailman/listinfo/python-list

Re: Python extension using a C library with one 'hello' function

2014-11-04 Thread Veek M
Jason Swails wrote: > I've submitted a PR to your github repo showing you the changes > necessary to get your module working on my computer. Segfaults :p which is an improvement :) open("./_hello.cpython-32mu.so", O_RDONLY) = 5 read(5, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\300\7\0\0\0

Re: Python extension using a C library with one 'hello' function

2014-11-04 Thread Søren
I'm not sure if it fits your needs, but we are very happy with calling c libs directly from python using ctypes: https://docs.python.org/2/library/ctypes.html It requires a few extra lines in Python to handle the parameter and return types. import ctypes result = ctypes.windll.Hello.hello()

Re: Python extension using a C library with one 'hello' function

2014-11-04 Thread Jason Swails
On Tue, 2014-11-04 at 16:22 +0630, Veek M wrote: > https://github.com/Veek/Python/tree/master/junk/hello > doesn't work. > I have: > hello.c which contains: int hello(void); > hello.h > > To wrap that up, i have: > hello.py -> _hello (c extension) -> pyhello.c -> method py_hello() > > People usin

Re: Python extension using a C library with one 'hello' function

2014-11-04 Thread Chris Angelico
On Tue, Nov 4, 2014 at 8:52 PM, Veek M wrote: > https://github.com/Veek/Python/tree/master/junk/hello > doesn't work. > I have: > hello.c which contains: int hello(void); > hello.h > > To wrap that up, i have: > hello.py -> _hello (c extension) -> pyhello.c -> method py_hello() > > People using th

Python extension using a C library with one 'hello' function

2014-11-04 Thread Veek M
https://github.com/Veek/Python/tree/master/junk/hello doesn't work. I have: hello.c which contains: int hello(void); hello.h To wrap that up, i have: hello.py -> _hello (c extension) -> pyhello.c -> method py_hello() People using this will do: python3.2>> import hello python3.2>> hello.hello() I