I've been looking for a way to ensure that certain modules don't end up in a wheel, while the rest of the package they reside in does. If I only cared about sdist, I could add a MANIFEST.in, in which I'd exclude those specific files, however, unfortunately, MANIFEST.in has no effect on bdists (at least of the wheel kind).
The use case is that our application auto-generates a parser and lexer with ply, and that parser might not work with different versions of ply. Since we don't have a whole lot of control over what version users have installed in their environments, we'd like to generate those modules in the target environment.
I took a deep dive into distutils and setuptools, and as far as I can see, any Python modules residing inside a package listed in the packages argument to setup() are included in the distribution unconditionally. Searching this mailing list only reveals a short thread from nine years ago  without any solution...
For now, the easiest hacky solution for me is to add a couple of os.remove calls to setup.py, but I'm not a big fan of setup.py messing with the source tree.
And as a follow-up question, is there any post-installation hook that we could use to trigger regeneration of those files?