bt2: run swig by hand instead of through "setup.py build_ext"
When we build the bt2 Python module, we call "setup.py build_ext", which
runs swig to generate the .c file from .i files and builds the native
library. We then run "setup.py build" to copy the Python files over to
build_lib directory.
However, "setup.py build" insists on running "build_ext" itself, seeing
that we have an ext_modules entry in our setup.py. This results in the
.i -> .so process being run twice. It's a bit wasteful to do the
process twice, but in itself it's not a big problem.
A bigger problem is that the second time swig is ran (through "setup.py
build"), it is done without honoring the SWIG Makefile variable. Here, I
have configured my build to use SWIG=/tmp/swig/bin/swig, and the two
swig invocations are:
/tmp/swig/bin/swig -python -I/home/simark/src/babeltrace/include -o bt2/native_bt_wrap.c bt2/native_bt.i
swig -python -I/home/simark/src/babeltrace/include -o bt2/native_bt_wrap.c bt2/native_bt.i
This means that trying to use a custom swig executable through the SWIG
configuration variable will not work, as it will always be overwritten
by the output of the "swig" in the path.
I haven't found a way to get the right swig executable to be used the
second time:
- "setup.py build" doesn't have a --swig option
- We can't use swig= in setup.py
- We can't override using an environment variable
The solution I found was to run swig ourselves to generate the .c file,
and feed that to the native extension built with distutils. We now
don't need to call build_ext explicitly, since the call done through
"build" is sufficient. It therefore fixes both problems: swigging and
building the library is now done only once, and the right swig
executable is used.
Change-Id: I9ed9d22fae1f5675d42af08e77607515dfdf788a
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1711
Reviewed-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
This page took 0.026225 seconds and 4 git commands to generate.