matthew-brett / delocate

Find and copy needed dynamic libraries into python wheels
BSD 2-Clause "Simplified" License
262 stars 59 forks source link

This function does not support separate values per-architecture: 'i386' #153

Open alexsavulescu opened 2 years ago

alexsavulescu commented 2 years ago

Describe the bug running delocate-wheel for an arm64-only wheel with universal2 python installation:

otool: /opt/X11/lib/libSM.6.dylib
Traceback (most recent call last):
  File "/Users/savulesc/Workspace/nrn/nrn_build_venv38_-2850068/bin/delocate-wheel", line 8, in <module>
    sys.exit(main())
  File "/Users/savulesc/Workspace/nrn/nrn_build_venv38_-2850068/lib/python3.8/site-packages/delocate/cmd/delocate_wheel.py", line 128, in main
    copied = delocate_wheel(
  File "/Users/savulesc/Workspace/nrn/nrn_build_venv38_-2850068/lib/python3.8/site-packages/delocate/delocating.py", line 643, in delocate_wheel
    copied_libs = delocate_path(
  File "/Users/savulesc/Workspace/nrn/nrn_build_venv38_-2850068/lib/python3.8/site-packages/delocate/delocating.py", line 465, in delocate_path
    lib_dict = tree_libs_from_directory(
  File "/Users/savulesc/Workspace/nrn/nrn_build_venv38_-2850068/lib/python3.8/site-packages/delocate/libsana.py", line 384, in tree_libs_from_directory
    return _tree_libs_from_libraries(
  File "/Users/savulesc/Workspace/nrn/nrn_build_venv38_-2850068/lib/python3.8/site-packages/delocate/libsana.py", line 309, in _tree_libs_from_libraries
    for depending_path, install_name in get_dependencies(
  File "/Users/savulesc/Workspace/nrn/nrn_build_venv38_-2850068/lib/python3.8/site-packages/delocate/libsana.py", line 105, in get_dependencies
    for install_name in get_install_names(lib_fname):
  File "/Users/savulesc/Workspace/nrn/nrn_build_venv38_-2850068/lib/python3.8/site-packages/delocate/tools.py", line 474, in get_install_names
    names_data = _check_ignore_archs(_parse_otool_install_names(otool.stdout))
  File "/Users/savulesc/Workspace/nrn/nrn_build_venv38_-2850068/lib/python3.8/site-packages/delocate/tools.py", line 324, in _check_ignore_archs
    raise NotImplementedError(
NotImplementedError: This function does not support separate values per-architecture: {'i386': [('/opt/X11/lib/libSM.6.dylib', '7.0.0', '7.1.0'), ('/opt/X11/lib/libICE.6.dylib', '10.0.0', '10.0.0'), ('/usr/lib/libSystem.B.dylib', '1.0.0', '1252.50.4')], 'x86_64': [('/opt/X11/lib/libSM.6.dylib', '7.0.0', '7.1.0'), ('/opt/X11/lib/libICE.6.dylib', '10.0.0', '10.0.0'), ('/usr/lib/libSystem.B.dylib', '1.0.0', '1311.120.1')], 'arm64': [('/opt/X11/lib/libSM.6.dylib', '7.0.0', '7.1.0'), ('/opt/X11/lib/libICE.6.dylib', '10.0.0', '10.0.0'), ('/usr/lib/libSystem.B.dylib', '1.0.0', '1311.120.1')]}

To Reproduce

delocate-wheel -w wheelhouse -v dist/*.whl. # from `build_wheels.bash` -> see `Wheels used` section

Expected behavior delocate-wheel works

Wheels used Attaching here.

Manual: Install universal2 Python 3.8.10 from Python.org ; XQuartz from xquartz.org (this installs to /opt/X11 where the issue is manifesting from) To create the wheel:

git clone git@github.com:neuronsimulator/nrn.git
cd nrn
bash packaging/python/build_static_readline_osx.bash
bash packaging/python/build_wheels.bash osx 3.8

Platform (please complete the following information):

Additional context If I pop the 'i386' from the dict passed to _check_ignore_archs it works. wheel.zip

HexDecimal commented 2 years ago

I had to put them side-by-side to understand:

{  'i386': [('/opt/X11/lib/libSM.6.dylib', '7.0.0', '7.1.0'), ('/opt/X11/lib/libICE.6.dylib', '10.0.0', '10.0.0'), ('/usr/lib/libSystem.B.dylib', '1.0.0', '1252.50.4')],
 'x86_64': [('/opt/X11/lib/libSM.6.dylib', '7.0.0', '7.1.0'), ('/opt/X11/lib/libICE.6.dylib', '10.0.0', '10.0.0'), ('/usr/lib/libSystem.B.dylib', '1.0.0', '1311.120.1')],
  'arm64': [('/opt/X11/lib/libSM.6.dylib', '7.0.0', '7.1.0'), ('/opt/X11/lib/libICE.6.dylib', '10.0.0', '10.0.0'), ('/usr/lib/libSystem.B.dylib', '1.0.0', '1311.120.1')]}

I personally wasn't expecting a lib with all three architectures, although I probably should have, and it's clear that ignoring i386 would be appropriate to have this link a universal2 binary.

I'm not sure what would be best here. Based on your workaround, maybe allowing the --require-archs flag to ignore architectures outside of what's specified could work, or use the architectures of the initial in-wheel libraries to determine which ones should be ignored.

I don't have the tools to make a proper test for this, and my setup doesn't make it easy to make contributions either. At most I could approve a PR. In your case you could upload your workaround to a personal branch and tell Pip to install delocate from that.

alexsavulescu commented 2 years ago

Thanks @HexDecimal , I will try to find some time next week to do a PR.