python-cffi

How to include external library with python wheel package

风格不统一 提交于 2019-11-27 20:19:23
问题 I want to create package for python that embeds and uses an external library ( .so ) on Linux using the cffi module. Is there standard way to include .so file into python package? The package will be used only internally and won't be published to pypi. I think Wheel packages are the best option - they would create platform specific package with all files ready to be copied so there will be no need to build anything on target environments. 回答1: You can use auditwheel to inject the external

How to pass a Numpy array into a cffi function and how to get one back out?

烈酒焚心 提交于 2019-11-27 11:35:54
问题 I am developing an audio algorithm using Python and Numpy. Now I want to speed up that algorithm by implementing a part of it in C. In the past, I have done this using cython. Now I want to do the same thing using the new cffi. For testing purposes, I wrote a trivial C function: void copy(float *in, float *out, int len) { for (int i=0; i<len; i++) { out[i] = in[i]; } } Now I want to create two numpy arrays and have those be processed by this function. I figured out a way to do that: import