mesonbuild / meson-python

Meson PEP 517 Python build backend
https://mesonbuild.com/meson-python/
MIT License
118 stars 59 forks source link

Generation of extra `.lib` library files for each python module on windows #552

Closed ankith26 closed 4 months ago

ankith26 commented 6 months ago

This looks like a windows only thing where I see a .lib file for every .pyd file made by meson-python. In my understanding, these files would be unneeded, so they just increase the wheelsize while not being useful. Is there any reason for having these, and if not, can these be not installed?

rgommers commented 6 months ago

Thanks for the report @ankith26. I think your comment is correct - my understanding is that Windows import libraries (the .lib files you are seeing) should not be shipped to end users. They're only ~500 bytes per file so the size shouldn't matter too much, but it is a little sloppy.

I checked the numpy wheels, and they contain .lib files for 1.26.x (built with Meson) and not for 1.25.x (built with distutils).

These files are generated at build time and marked for install by Meson with a devel tag in intro-install_plan.json. The corresponding .pyd files have a runtime tag. meson-python has to install all files by default, but you can avoid installing devel files by selecting only the runtime and python-runtime tags; see https://mesonbuild.com/meson-python/how-to-guides/meson-args.html#how-to-guides-meson-args for how to add this to your pyproject.toml. Note that if you're installing other devel files (e.g., headers), this may not be as easy.

I'm not sure if there's anything that should change in Meson or meson-python's defaults. I suspect it's a little tricky, because:

ankith26 commented 6 months ago

I used the tag workaround you suggested, thanks!

rgommers commented 4 months ago

Thanks for the confirmation @ankith26. I forgot to close this earlier, but we're all good here it looks like.