Skip to content

Freezing With py2app: IOError: could not get source code #68

Open
@riggsd

Description

@riggsd

I'm attempting to "freeze" an application into a distributable OS X .app using py2app. I have slimmed my code down to the bare minimum which triggers this issue, but I don't understand enough of the magic to determine if the problem is truly with sounddevice, CFFI, py2app, or my configuration. Apologies if this is the wrong channel to start looking for a fix!

Once frozen, a simple import sounddevice causes the blowup. The exception is thrown when a C header is fed to CFFI as a giant string literal:

Traceback (most recent call last):
  File "sdtest/dist/sdtest.app/Contents/Resources/__boot__.py", line 77, in <module>
    _run()
  File "sdtest/dist/sdtest.app/Contents/Resources/__boot__.py", line 62, in _run
    exec(compile(source, path, 'exec'), globals(), globals())
  File "sdtest/dist/sdtest.app/Contents/Resources/sdtest.py", line 1, in <module>
    import sounddevice
  File "sounddevice.pyc", line 313, in <module>
  File "cffi/api.pyc", line 105, in cdef
  File "cffi/api.pyc", line 119, in _cdef
  File "cffi/cparser.pyc", line 299, in parse
  File "cffi/cparser.pyc", line 304, in _internal_parse
  File "cffi/cparser.pyc", line 260, in _parse
  File "cffi/cparser.pyc", line 40, in _get_parser
  File "pycparser/c_parser.pyc", line 116, in __init__
  File "pycparser/ply/yacc.pyc", line 3293, in yacc
  File "pycparser/ply/yacc.pyc", line 2938, in validate_all
  File "pycparser/ply/yacc.pyc", line 2982, in validate_modules
  File "inspect.pyc", line 690, in getsourcelines
  File "inspect.pyc", line 538, in findsource
IOError: could not get source code

My setup.py with py2app configuration is as follows; I've explicitly included the path to my compiled PortAudio lib (which magically installed with sounddevice) to ensure it is included within the the .app:

from setuptools import setup

PY2APP_OPTIONS = {
    'argv_emulation': False,
    'includes': ['sounddevice'],
    'frameworks': ['/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_sounddevice_data/libportaudio.dylib'],
}

setup(
    app=['sdtest.py'],
    options={'py2app': PY2APP_OPTIONS},
    setup_requires=['py2app'],
)

And the sdtest.py file itself need only be as simple as this to trigger this problem:

import sounddevice

Can you provide any suggestions as to how better to track down the problem here? I don't really understand what CFFI is doing under the hood, nor understand "who" is unable to find source code nor what source it's looking for.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions