Excluding specific Python modules from wheels

Hello everyone, 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 [1] 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? Any ideas? Michal [1]: https://mail.python.org/mm3/archives/list/distutils-sig@python.org/message/N...

I am currently working on implementing a "wheel repack" command which lets you unpack a wheel, modify it and then repack it again while keeping the wheel RECORD consistent. I think this is something that would solve your use case. ke, 2018-05-30 kello 10:07 +0200, Michal Petrucha kirjoitti:

Hi, On Wed, May 30, 2018 at 10:29 PM, <alex.gronholm@nextday.fi> wrote:
I wrote something similar a while back, of form: with InWheel(original_wheel_fname, output_wheel_fname): # You are now in the root directory of the unpacked wheel. # Do what you will. The resulting files get packed up into the output wheel. # The record file adapted accordingly. https://github.com/matthew-brett/delocate/blob/master/delocate/wheeltools.py Cheers, Matthew

I am currently working on implementing a "wheel repack" command which lets you unpack a wheel, modify it and then repack it again while keeping the wheel RECORD consistent. I think this is something that would solve your use case. ke, 2018-05-30 kello 10:07 +0200, Michal Petrucha kirjoitti:

Hi, On Wed, May 30, 2018 at 10:29 PM, <alex.gronholm@nextday.fi> wrote:
I wrote something similar a while back, of form: with InWheel(original_wheel_fname, output_wheel_fname): # You are now in the root directory of the unpacked wheel. # Do what you will. The resulting files get packed up into the output wheel. # The record file adapted accordingly. https://github.com/matthew-brett/delocate/blob/master/delocate/wheeltools.py Cheers, Matthew
participants (3)
-
alex.gronholm@nextday.fi
-
Matthew Brett
-
Michal Petrucha