Setuptools: Automatically include headers in sdist

Created on 2 Oct 2017  路  2Comments  路  Source: pypa/setuptools

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!)
Needs Triage

Most helpful comment

All 2 comments

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.

Was this page helpful?
0 / 5 - 0 ratings