Automatically include headers in sdist
Currently, sdists do not automatically include headers for extension modules. However, the information of headers is in fact already present and could easily be added: it is (or rather, should be) included in the depends field of the Extension objects (https://docs.python.org/3.6/distutils/apiref.html?highlight=depends#distutils.core.Extension), as one will usually want to recompile the extension if one of the headers is changed (just as one wants to recompile the extension if one of the source files is changed).
Adding
self.filelist.extend(depend
for ext in build_ext.extensions
for depend in ext.depends)
in py36compat's _add_defaults_ext is sufficient to obtain the desired behavior.
Note the comment in the docstring of add_defaults:
- all C sources listed as part of extensions or C libraries
in the setup script (doesn't catch C headers!)
In the docstring for that class, it mentions "Do not edit the code in this class except to update functionality as implemented in distutils. Instead, override in the subclass." That class is there to provide forward compatibility on older Pythons.
So the question is - should setuptools provide this additional functionality on its own, or should the additional functionality first be added to CPython and then back-ported by setuptools?
My preference would be the latter.
Lots of people have trouble with this issue.
-
https://stackoverflow.com/questions/6633624/how-to-specify-header-files-in-setup-py-script-for-python-extension-module
-
https://bitbucket.org/blais/beancount/src/ccb3721a7811a042661814a6778cca1c42433d64/setup.py?fileviewer=file-view-default#setup.py-36
-
https://github.com/pypa/packaging-problems/issues/84
I think the community would greatly appreciate a fix to this, in setuptools rather than waiting for distutils to do something about it.
adding MANIFEST.in file helps, I also struggled with this a lot