pantor / ruckig

Motion Generation for Robots and Machines. Real-time. Jerk-constrained. Time-optimal.
https://ruckig.com
MIT License
635 stars 155 forks source link

ruckig pypi package for macos mislabeled as universal2 #175

Closed hashb closed 5 months ago

hashb commented 6 months ago

tl,dr: ruckig macos binaries uploaded to pypi are mislabeled as universal2 and do not work on M1 macs

I recently ran into issues when trying to use python 3.11 pypi package of ruckig.

$ python 01_position.py      main?
Traceback (most recent call last):
  File "/Users/<path>/ruckig/examples/01_position.py", line 3, in <module>
    from ruckig import InputParameter, OutputParameter, Result, Ruckig
ImportError: dlopen(/Users/<path>/lib/python3.11/site-packages/ruckig.cpython-311-darwin.so, 0x0002): tried: '/Users/<path>/lib/python3.11/site-packages/ruckig.cpython-311-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/<path>/lib/python3.11/site-packages/ruckig.cpython-311-darwin.so' (no such file), '/Users/<path>/lib/python3.11/site-packages/ruckig.cpython-311-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))

I did a bit of digging into the pypi package ruckig-0.9.2-cp311-cp311-macosx_12_0_universal2.whl and it turns out it is not a real universal2 binary.

This is the output I get when I try to check the shared object's arch

$ file -b ruckig.cpython-311-darwin.so 
Mach-O 64-bit bundle x86_64

What the expected output of a universal binary should look like

$ file -b _sodium.abi3.so 
Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit bundle x86_64] [arm64:Mach-O 64-bit bundle arm64]
_sodium.abi3.so (for architecture x86_64):  Mach-O 64-bit bundle x86_64
_sodium.abi3.so (for architecture arm64):   Mach-O 64-bit bundle arm64

based on this post https://stackoverflow.com/a/65811061, I added "-DCMAKE_OSX_ARCHITECTURES=arm64;x86_64", to setup.py and was able to build universal binaries.

$ file -b ruckig.cpython-311-darwin.so                                                                                                                                                  main!?
Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit bundle x86_64] [arm64:Mach-O 64-bit bundle arm64]
ruckig.cpython-311-darwin.so (for architecture x86_64): Mach-O 64-bit bundle x86_64
ruckig.cpython-311-darwin.so (for architecture arm64):  Mach-O 64-bit bundle arm64

related upstream issue https://github.com/pypa/wheel/issues/406

pantor commented 5 months ago

Thanks for pointing this out! I've reworked the complete Python wheel pipeline (now using scikit-build-core), and this should be fixed now.