From e4c355270f7062f98b8b8a7e41fab77370af9250 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Br=C3=A9nainn=20Woodsend?= Date: Thu, 14 May 2026 14:17:25 +0100 Subject: [PATCH 1/2] Fix architecture detection on Windows ARM64 When running an AMD64 Python on a Windows ARM64 host, platform.machine() returns the host architecture instead of the process architecture, causing sounddevice to try and load the wrong DLL. >>> import sounddevice Traceback (most recent call last): File "C:\Users\bagpuss\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\sounddevice.py", line 72, in raise OSError('PortAudio library not found') OSError: PortAudio library not found During handling of the above exception, another exception occurred: Traceback (most recent call last): File "", line 1, in import sounddevice File "C:\Users\bagpuss\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\sounddevice.py", line 91, in _lib: ... = _ffi.dlopen(_libname) ~~~~~~~~~~~^^^^^^^^^^ OSError: cannot load library 'C:\Users\bagpuss\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\_sounddevice_data\portaudio-binaries\libportaudioarm64.dll': error 0x7e The PROCESSOR_ARCHITECTURE environment variable can be used to get process architecture. As far as I know, it should always be enough to only check that variable but I wasn't feeling brave enough to not leave the old detection as a fallback. --- src/sounddevice.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/sounddevice.py b/src/sounddevice.py index 00fc6f8..4361c62 100644 --- a/src/sounddevice.py +++ b/src/sounddevice.py @@ -75,10 +75,16 @@ if _platform.system() == 'Darwin': _libname = 'libportaudio.dylib' elif _platform.system() == 'Windows': - if _platform.machine().lower() in ('arm64', 'aarch64'): - _platform_suffix = 'arm64' - else: - _platform_suffix = _platform.architecture()[0] + _platform_suffix = { + 'AMD64': '64bit', + 'x86': '32bit', + 'ARM64': 'arm64', + }.get(_os.environ.get('PROCESSOR_ARCHITECTURE', ''), '') + if not _platform_suffix: + if _platform.machine().lower() in ('arm64', 'aarch64'): + _platform_suffix = 'arm64' + else: + _platform_suffix = _platform.architecture()[0] if 'SD_ENABLE_ASIO' in _os.environ: _libname = 'libportaudio' + _platform_suffix + '-asio.dll' else: From 376db565858416e437774076831dc60fdad9f79d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Br=C3=A9nainn=20Woodsend?= Date: Thu, 14 May 2026 21:04:50 +0100 Subject: [PATCH 2/2] Add Windows x64 on ARM64 variant to CI --- .github/workflows/sounddevice-data.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sounddevice-data.yml b/.github/workflows/sounddevice-data.yml index 5bdfaad..a566835 100644 --- a/.github/workflows/sounddevice-data.yml +++ b/.github/workflows/sounddevice-data.yml @@ -16,6 +16,8 @@ jobs: arch: 'x86' - os: windows-11-arm arch: 'arm64' + - os: windows-11-arm + arch: 'x64' runs-on: ${{ matrix.os }} steps: - name: Set up Python @@ -25,7 +27,7 @@ jobs: architecture: ${{ matrix.arch }} - name: Double-check Python version run: | - python --version + python --version --version - name: Clone Git repository (with submodules) uses: actions/checkout@v6 with: