Hi,
On 8 June 2016 at 04:26, Victor Blomqvist <
v...@viblo.se> wrote:
> Currently and before when I used ctypes I used to compile the c-library
> myself and then put the compiled files inside my package folder. Is this the
> best way?
There is no "known best way", but I can only repeat the way I
recommend---though it is not better than yours in all aspects. This
is using the modern API mode:
root/
chipmunk_src/
c library source files
pymunk_build.py
pymunk/
python code files
The pymunk_build.py is a build file like
http://cffi.readthedocs.io/en/latest/overview.html#real-example-api-level-out-of-line
. It specifies the C library source files as an extra
``sources=[files]`` argument to set_source(). In this way, by running
pymunk_build.py once, you compile both the C library and the CFFI
bindings together, and produce a single .dll/.so that can be used
directly from Python ("import ..."). Just like your solution, you get
a single .dll/.so. The advantage is that you don't have to use the
ABI mode (the API mode is safer and faster). The disadvantage is that
the .dll/.so is specific to a Python version.
This disadvantage could also be considered an "advantage", as this is
a standard case for Python's wheel packaging system. (In your
solution, I don't know if you can hack wheels to get a binary wheel
that is still independent on the Python version. Maybe you should not
use wheels at all for that, but somehow consider the .dll as a data
file that happens to be distributed with your package.)
A bientôt,
Armin.