Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python3 soundfile doesn't work on macOS/M1 #444

Closed
ohmtech-rdi opened this issue Jun 11, 2022 · 2 comments
Closed

Python3 soundfile doesn't work on macOS/M1 #444

ohmtech-rdi opened this issue Jun 11, 2022 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@ohmtech-rdi
Copy link
Owner

ohmtech-rdi commented Jun 11, 2022

Python3 soundfile doesn't work on macOS M1.

Steps to reproduce

% pip3 install sound file
...
% pip3 list | grep SoundFile
SoundFile         0.10.3.post1
% python3
Python 3.9.13 (main, May 24 2022, 21:13:51) 
[Clang 13.1.6 (clang-1316.0.21.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import soundfile
Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.9/site-packages/soundfile.py", line 142, in <module>
    raise OSError('sndfile library not found')
OSError: sndfile library not found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/homebrew/lib/python3.9/site-packages/soundfile.py", line 162, in <module>
    _snd = _ffi.dlopen(_os.path.join(
OSError: cannot load library '/opt/homebrew/lib/python3.9/site-packages/_soundfile_data/libsndfile.dylib': dlopen(/opt/homebrew/lib/python3.9/site-packages/_soundfile_data/libsndfile.dylib, 0x0002): tried: '/opt/homebrew/lib/python3.9/site-packages/_soundfile_data/libsndfile.dylib' (no such file)

There is no _soundfile_data in the site-packages/ folder.

However the SoundFile project is working on a new 0.11 release to address this problem, which details are captured in this issue.

The 0.11 release is still pre-release, with b5 just 9 days ago (relative to the time of this post).

Workarounds

It is possible to install libsndfile from brew, and then copy it in the _soundfile_data folder as described above.

Fix

It is not the first time that our dependencies fails to install. We are only using a very small part of libsndfile, as we officially only support the wav format. Furthermore SoundFile doesn't support all functions of the library, and we need to access the cue markers later in the project.
So one way to solve this would be to make our WAV parser directly in Python to remove this dependency.

@ohmtech-rdi ohmtech-rdi added the bug Something isn't working label Jun 11, 2022
@ohmtech-rdi ohmtech-rdi self-assigned this Jun 11, 2022
@ohmtech-rdi ohmtech-rdi changed the title Python3 soundfile doesn't work on macOS M1 Python3 soundfile doesn't work on macOS/M1 Jun 11, 2022
@ohmtech-rdi
Copy link
Owner Author

Workaround shell session for reference:

% brew install libsndfile
...
% brew list libsndfile
...
/opt/homebrew/Cellar/libsndfile/1.1.0/lib/libsndfile.1.dylib
/opt/homebrew/Cellar/libsndfile/1.1.0/lib/libsndfile.dylib
% ls -l /opt/homebrew/Cellar/libsndfile/1.1.0/lib/
total 912
-r--r--r--  1 raf  admin  466656 Jun 12 14:42 libsndfile.1.dylib
lrwxr-xr-x  1 raf  admin      18 Mar 27 14:42 libsndfile.dylib -> libsndfile.1.dylib
drwxr-xr-x  3 raf  admin      96 Jun 12 14:42 pkgconfig
% mkdir -p /opt/homebrew/lib/python3.9/site-packages/_soundfile_data
% cp /opt/homebrew/Cellar/libsndfile/1.1.0/lib/libsndfile.1.dylib /opt/homebrew/lib/python3.9/site-packages/_soundfile_data/
% python3
Python 3.9.13 (main, May 24 2022, 21:13:51) 
[Clang 13.1.6 (clang-1316.0.21.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import soundfile
>>>

@ohmtech-rdi
Copy link
Owner Author

ohmtech-rdi commented Jun 2, 2023

SoundFile 0.12.1 version of libsndfile now supports M1 Mac, but relies on pip at least version 22.2 because wheel universal2 tag appeared in 22.2, and SoundFile relies on it to install binary packages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant