I am writing a Cython wrapper for a C ++ library that I would like to distribute as a Python package. I came up with a dummy version of my package that looks like this (full source here ).
$ tree
.
├── bogus.pyx
├── inc
│ └── bogus.hpp
├── setup.py
└── src
└── bogus.cpp
$
$ cat inc/bogus.hpp
class bogus
{
protected:
int data;
public:
bogus();
int get_double(int value);
};
$
$ cat src/bogus.cpp
bogus::bogus() : data(0)
{
}
int bogus::get_double(int value)
{
data = value * 2;
return data;
}
$ cat bogus.pyx
cdef extern from 'bogus.hpp':
cdef cppclass bogus:
bogus() except +
int get_double(int value)
cdef class Bogus:
cdef bogus b
def get_double(self, int value):
return self.b.get_double(value)
With the following setup.pyfile, I can confirm that the library is correctly installed with python setup.py installand that it works correctly.
from setuptools import setup, Extension
import glob
headers = list(glob.glob('inc/*.hpp'))
bogus = Extension(
'bogus',
sources=['bogus.pyx', 'src/bogus.cpp'],
include_dirs=['inc/'],
language='c++',
extra_compile_args=['--std=c++11', '-Wno-unused-function'],
extra_link_args=['--std=c++11'],
)
setup(
name='bogus',
description='Troubleshooting Python packaging and distribution',
author='Daniel Standage',
ext_modules=[bogus],
install_requires=['cython'],
version='0.1.0'
)
However, when I build the source distribution with python setup.py sdist build, the C ++ header files are not included and the C ++ extension cannot be compiled.
How can I make sure that the C ++ header files are associated with the source distribution?!?!
pompous
, , . graft MANIFEST.in? . package_data data_files? . Python , , Python, - .
</& GT;