jwodder / check-wheel-contents

Check your wheels have the right contents

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add a check for binaries having correct architecture in cross build environments

raymanP opened this issue · comments

Hi,
when building multiple architectures in cross build environment wrong architecture can happen to build, e.g. x86_64 instead of aarch64. This could be checked using file to the binaries.

For example building package-1.6.9-cp37-cp37m-linux_aarch64.whl
containing:

package/
module.cpython-37m-aarch64-linux-gnu.so

check that file architecture:
e.g. file module.cpython-37m-aarch64-linux-gnu.so returns
module.cpython-37m-aarch64-linux-gnu.so: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, stripped

A wrong architecture would return for example:

  • armv7l: ....so: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, stripped
  • x86_64: ....so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=cfeef54b3b6f07621a242d8b4ea336c926be74c0, stripped
  • i686: ....so: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, BuildID[sha1]=7d289cf9b0f011f82c8af9171a642bc1bec31ac4, stripped
  • macOS intel 64: ....so: Mach-O 64-bit x86_64 bundle, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL>
  • macOS arm 64: ....so: Mach-O 64-bit arm64 bundle, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL>
  • win x32: ....pyd: PE32 executable (DLL) (GUI) Intel 80386, for MS Windows, 5 sections
  • win x64: ....pyd: PE32+ executable (DLL) (GUI) x86-64, for MS Windows, 6 sections

Under Linux/macOS the binaries are .so files and under Windows these are .pyd files.

Possible argument could be: --check-arch "ARM aarch64"
Maybe is also possible some auto check from wheel tag, like: Tag: cp37-cp37m-linux_aarch64 or from the wheel file name

Regards, Reimund