markmc / rebuilding-the-wheel

1 stars 2 forks source link

lean wheels #81

Open dhellmann opened 3 months ago

dhellmann commented 3 months ago

How would we produce lean wheels? Can we move some dependencies that trigger fat builds to RPM-based system libraries? Can we build smaller, ABI-specific, packages even if some dependencies are included?

See also #76

tiran commented 3 months ago

Binary wheels start as lean wheels without bundled dependencies. Wheels are converted to fat wheels by auditwheel. The tool analysis shared libraries, embeds dependencies into the wheel, and rewrites all shared libraries with patchelf.

In most cases we don't need to do anything to get lean wheels. Some packages vendor and bundle libraries in the sdist, though. They need extra steps or options to de-bundle the code.

We can detect shared library RPM dependencies easily with elfdeps:

$ /usr/lib/rpm/elfdeps --requires /usr/lib64/python3.12/site-packages/_ldap.cpython-312-x86_64-linux-gnu.so
liblber.so.2(OPENLDAP_2.200)(64bit)
libc.so.6(GLIBC_2.14)(64bit)
libc.so.6(GLIBC_2.4)(64bit)
libc.so.6(GLIBC_2.2.5)(64bit)
libc.so.6(GLIBC_2.3.4)(64bit)
libldap.so.2(OPENLDAP_2.200)(64bit)
libldap.so.2()(64bit)
liblber.so.2()(64bit)
libc.so.6()(64bit)
rtld(GNU_HASH)

The dependency name are resolved by dnf (although it seems to be a bit slow)

$ sudo dnf install 'libldap.so.2(OPENLDAP_2.200)(64bit)' 'libc.so.6(GLIBC_2.3.4)(64bit)'
Last metadata expiration check: 1:17:01 ago on 2024-04-15T12:43:52 CEST.
Package openldap-2.6.6-1.fc39.x86_64 is already installed.
Package glibc-2.38-16.fc39.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!