I'm trying to generate Python bindings for some C++ code using SWIG.
It created some blah_wrap.cxx
and blah.py
files.
I then created this setup.py
from distutils.core import setup, Extension
ext = Extension('_ev3',
sources=[
'ev3_serial_wrap.cxx',
'ev3_serial.hpp'
'ev3_motor_wrap.cxx',
'ev3_motor.hpp'
'ev3_i2c_wrap.cxx',
'ev3_i2c.hpp'
'ev3_analog_wrap.cxx',
'ev3_analog.hpp'
],
language='c++',
)
setup (name = 'evpy',
version = '0.1',
author = "Pepijn de Vos",
description = """
An EV3 API.
""",
ext_modules = [ext],
packages=['evpy'],
)
But then I get
$ python3 setup.py build
running build
running build_py
running build_ext
building '_ev3' extension
error: unknown file type '.hpp' (from 'ev3_analog.hpp')
.hpp
is a pretty standard C++ extensions right? Why not .cpp
? I don't know, the author of the original code put the implementation in his header files.
Are you sure header files are supposed to go in the sources argument, and not in another like headers?