Skip to content

Commit 5094061

Browse files
committed
Find libsndfile.dylib on Apple M1
Homebrew on Apple M1 uses a `/opt/homebrew/lib` instead of `/usr/local/lib`. We are making sure we pick that up.
1 parent 744efb4 commit 5094061

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

soundfile.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import os as _os
1414
import sys as _sys
15+
from platform import machine as _machine
1516
from os import SEEK_SET, SEEK_CUR, SEEK_END
1617
from ctypes.util import find_library as _find_library
1718
from _soundfile import ffi as _ffi
@@ -159,8 +160,14 @@
159160
while not _os.path.isdir(_path):
160161
_path = _os.path.abspath(_os.path.join(_path, '..'))
161162

162-
_snd = _ffi.dlopen(_os.path.join(
163-
_path, '_soundfile_data', _libname))
163+
# Homebrew on Apple M1 uses a `/opt/homebrew/lib` instead of
164+
# `/usr/local/lib`. We are making sure we pick that up.
165+
if _sys.platform == 'darwin' and _machine() == 'arm64':
166+
_snd = _ffi.dlopen(_os.path.join(
167+
'/opt/homebrew/lib/', _libname))
168+
else:
169+
_snd = _ffi.dlopen(_os.path.join(
170+
_path, '_soundfile_data', _libname))
164171

165172
__libsndfile_version__ = _ffi.string(_snd.sf_version_string()).decode('utf-8', 'replace')
166173
if __libsndfile_version__.startswith('libsndfile-'):

0 commit comments

Comments
 (0)