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
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!
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.
K.Danilov aka KoDer
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:
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,
static PyObject *
cpp_foo(PyObject *self, PyObject* args)
int i, len;
if(!PyArg_ParseTuple(args, "O", &obj))
seq = PySequence_Fast(obj, "expected a sequence");
len = PySequence_Size(obj);
for (i=0; i<len; i++)
a=item; // ?????????????????????????????????????????
suggested to try to ask capi-sig for this question.
---------- 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?
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/