I agree that auditwheel would be a good place for this. There’s a lot of logic for scanning and repacking wheel files that could be shared across platforms. And it’s already very challenging for package maintainers to understand all the different platforms well enough to build wheels on all of them. Being able to use the same tool on different platforms will make this a little bit easier.
I don’t have the time to work on this myself, but I did implement the core primitive you need a while ago, and I would be delighted to see it integrated into auditwheel: https://github.com/njsmith/machomachomangler
I think the pieces you need are:
- Scan the wheel to find PE format files (DLLs and EXEs)
- For each PE file, extract the list of DLLs that it links to – IIRC machomachomangler can do this, or probably lots of PE libraries can
- Compare those to some list of which libraries are built into Windows and don’t need vendoring. This will probably need refinement over time, but you can probably get close by looking at a fresh Windows install. Or maybe Steve Dower can help.
- For libraries which do need vendoring, move them into a directory in the wheel, and mangle their names, like how we do on Linux. AFAIK machomachomangler is the only existing tool for this part.
- Possibly the most annoying part: windows doesn’t have an equivalent of RPATH. So we need to rewrite the wheel’s top-level
__init__.py and inject some code to add our vendored libs dir to the DLL search path. There are a lot of ways to approach this, they’re all kinda gross, but I think we can hold our noses and make it work in practice.
I’m on my phone so can’t easily look up their usernames, but someone should probably CC Matthew Brett and the auditwheel maintainers into this thread.