Hello all,
I would like to use an existing C-Function from python. Therfore I made
up an wrapper (wrap.c), where all the variable transformations from
Python to C are done. That works. Now I would like to call the external
fuction, which is placed in lets say ext_foo.a with a corresponding
ext_foo.h and can be used as a library from plain C.
I am assuming, that I do have to include the ext_foo.h in my wrap.c with
#include "ext_foo.h"
that I have to introduce the function in my C-Code:
extern int foo(int);
that I have to tell the setup.py using the distutils stuff where the
library can be found...
when compiling a C-Code which is not for python usage I do type
gcc -o test.o ./test.c ./ext_foo.a -I./foo_h_file_path/
and everything is fine,
where within these setup.py files do I have to mention the ./ext_foo.a ?
When I do place it in the sources-tag, setup procedure complains that it
doesn't know any .a files... if I don't mention it explicitly, just
giving the include_dirs, compilation works fine, but when importing from
python 'import wrap' I do get the message: Symbol not found: _foo
Any help is very much appreciated!
Thanks
Philipp
2008/11/12 Stefan Behnel <stefan_ml(a)behnel.de>:
> Philipp Heuser wrote:
>> I am just starting to use the C API for Python. What I want to do is to
>> use an external funtion availabele in C and therfore I want to 'convert'
>> a list of floats from Python to an array of floats in C
>
> Since you're just starting, it's generally worth looking into Cython
> first, before investing time to learn the raw Python C-API.
>
> http://cython.org/
>
Or http://cxx.sourceforge.net/
--
K.Danilov aka KoDer
ICQ:214286120
Skype:koder.ua
Tel:8-050-4030512
Jabber:koder_ua@jabber.ru
Hi all,
I am just starting to use the C API for Python. What I want to do is to
use an external funtion availabele in C and therfore I want to 'convert'
a list of floats from Python to an array of floats in C which I can
forward to the external function. So first step is tp parse a list to C
and let the C code print the variables! The obviously too simplistic
approach is below... When I call this function from python, e.g.
cpp([1,2,3]) the output is:
25180552
25180540
25180528
Could you be so kind to help me here to get started with using
C-functions from Python? Where is the error?
Thank you very much and kind regards,
Philipp
static PyObject *
cpp_foo(PyObject *self, PyObject* args)
{
PyObject* obj;
PyObject* seq;
int i, len;
if(!PyArg_ParseTuple(args, "O", &obj))
return NULL;
seq = PySequence_Fast(obj, "expected a sequence");
len = PySequence_Size(obj);
PyObject* item;
int a;
for (i=0; i<len; i++)
{
item=PySequence_Fast_GET_ITEM(seq, i);
a=item; // ?????????????????????????????????????????
printf("%i\n", a);
}
Py_DECREF(seq);
return None;
}
suggested to try to ask capi-sig for this question.
Forwarding.
---------- Forwarded message ----------
From: Aahz <aahz(a)pythoncraft.com>
Date: Thu, Nov 6, 2008 at 1:08 AM
Subject: Re: Can I build Python with lthread instead of pthread?
To: python-list(a)python.org
In article <mailman.3365.1225472233.3487.python-list(a)python.org>,
Akira Kitada <akitada(a)gmail.com> wrote:
>
>I'm running Python 2.5 on FreeBSD 4.
>pthread on FreeBSD 4 has some problems so I would like to build
>python with lthread (linuxthreads) instead of BSD's pthread.
>So I looked at configure options but couldn't find any options for it.
>Python support lthread? and how can I build python with it?
You may want to try asking on capi-sig
--
Aahz (aahz(a)pythoncraft.com) <*> http://www.pythoncraft.com/
import antigravity
--
http://mail.python.org/mailman/listinfo/python-list