Portaudio Bundled but location is local?

35 views
Skip to first unread message

Mateo J

unread,
Jul 31, 2023, 12:04:54 PM7/31/23
to PyInstaller
Hi, my code works, and bundling works. 

However when I add the need for portaudio in my code it appears that the hook runs and loads the correct bundles into the onefile locations, but when running the application it looks for the portaudio in another location (my local install).

To be clear:
Console error:

Library Validation failed: Rejecting '/opt/homebrew/Cellar/portaudio/19.7.0/lib/libportaudio.2.dylib' (Team ID: none, platform: no) for process 'pypy(12758)' (Team ID: N12B3X14HN, platform: no), reason: mapped file has no Team ID and is not a platform binary (signed with custom identity or adhoc?)

The issue is NOT codesigning, I manually sign everything fine, the issue is that it is attempting to load a local copy of portaudio and NOT the one bundled (which is signed).

Any idea what to do or how to track down? I looked in warn log but didn't see this mentioned.

My spec is pretty standard, thanks for any help!:

# -*- mode: python ; coding: utf-8 -*-


block_cipher = None


a = Analysis(
    ['pypy.py'],
    pathex=[],
    binaries=[],
    datas=[],
    hiddenimports=[],
    hookspath=[],
    hooksconfig={},
    runtime_hooks=[],
    excludes=[],
    win_no_prefer_redirects=False,
    win_private_assemblies=False,
    cipher=block_cipher,
    noarchive=False,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)

exe = EXE(
    pyz,
    a.scripts,
    [],
    exclude_binaries=True,
    name='pypy',
    debug=1,
    bootloader_ignore_signals=False,
    strip=False,
    upx=True,
    console=True,
    disable_windowed_traceback=False,
    argv_emulation=False,
    target_arch=None,
    codesign_identity='Developer ID...',
    entitlements_file='',
    icon=['icons/pypy.png'],
)
coll = COLLECT(
    exe,
    a.binaries,
    a.zipfiles,
    a.datas,
    strip=False,
    upx=True,
    upx_exclude=[],
    name='pypy',
)
app = BUNDLE(
    coll,
    name='pypy.app',
    icon='./icons/pypy.png',
    bundle_identifier='com.me.pypy',
    info_plist={
        "NSHighResolutionCapable":True,
        "com.apple.security.automation.apple-events":True,
        "NSMicrophoneUsageDescription":"This will be used to analyze slurring",
        "com.apple.security.device.microphone":True,
        "com.apple.security.device.audio-input":True
    }
)

bwoodsend

unread,
Aug 2, 2023, 2:39:44 AM8/2/23
to PyInstaller

PyPI packages that depend on Homebrew are always painful. otool -L (roughly equivalent to Linux’s ldd) is your go-to tool for this. The original unfrozen copy of pyaudio‘s extension module will be linked against libportaudio.*.dylib from Homebrew using an absolute path:

$ otool -L ./env/lib/python3.10/site-packages/pyaudio/_portaudio.cpython-310-darwin.so ./env/lib/python3.10/site-packages/pyaudio/_portaudio.cpython-310-darwin.so: /opt/homebrew/opt/portaudio/lib/libportaudio.2.dylib (compatibility version 3.0.0, current version 3.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.100.3)

Now PyInstaller is supposed to to replace that path with an @rpath (relative to the parent executable) entry so that your application is relocatable. That has worked fine for me:

$ otool -L ./dist/test/pyaudio/_portaudio.cpython-310-darwin.so ./dist/test/pyaudio/_portaudio.cpython-310-darwin.so: @rpath/libportaudio.2.dylib (compatibility version 3.0.0, current version 3.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.100.3)

Are you sure you’re not just running some out of date PyInstaller that predates linker path rewriting?

Reply all
Reply to author
Forward
0 new messages