Search code examples
pythonmacososx-snow-leopardpy2app

py2app: syntax error when running generated app


I have an app which is running ok when started from Python. I would like to use pyapp for packaging it on MAC OS 10.6.8.

The app is a small embedded webapp running with bottle microframework. It has been packages successfully on windows with py2exe.

I have the following py2app script

The setup.py py2app seems to be ok. I've a generated app file and I can see that it contains the right code. Hello, I have an app which is running ok when started from Python. I would like to use pyapp for packaging it on MAC OS 10.6.8.

The app is a small embedded webapp running with bottle microframework. It has been packages successfully on windows with py2exe.

I have the following py2app script

The setup.py py2app seems to be ok. I've a generated app file and I can see that it contains the right code.

from setuptools import setup
import sys, os, os.path
wapp_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

sys.path.append(wapp_path)

DATA_FILES = []

setup(
    app = [
        'nsav_ws.py',
    ],
    options={
        "py2app":{
            'argv_emulation': True, 
            "includes":["shelve", "dbhash", "sqlite3", "waitress", "runpy_imports", "bottle_sqlalchemy"],
            "packages": ["sqlalchemy.dialects.sqlite", "sqlalchemy", "nsav_wapp"],
        }
    },
   setup_requires=['py2app']
)

Unfortunately, the app fails on startup. Here is the traceback:

25/10/12 16:55:53   [0x0-0x118118].org.pythonmac.unspecified.nsav_ws[5126]  argvemulator warning: fetching events failed
25/10/12 16:55:53   [0x0-0x118118].org.pythonmac.unspecified.nsav_ws[5126]  Traceback (most recent call last):
25/10/12 16:55:53   [0x0-0x118118].org.pythonmac.unspecified.nsav_ws[5126]    File "/Users/luc/Dev/nelly_signe_avec_vous/nsav/nsav_mac/dist/nsav_ws.app/Contents/Resources/__boot__.py", line 340, in <module>
25/10/12 16:55:53   [0x0-0x118118].org.pythonmac.unspecified.nsav_ws[5126]      _run()
25/10/12 16:55:53   [0x0-0x118118].org.pythonmac.unspecified.nsav_ws[5126]    File "/Users/luc/Dev/nelly_signe_avec_vous/nsav/nsav_mac/dist/nsav_ws.app/Contents/Resources/__boot__.py", line 311, in _run
25/10/12 16:55:53   [0x0-0x118118].org.pythonmac.unspecified.nsav_ws[5126]      exec(compile(source, path, 'exec'), globals(), globals())
25/10/12 16:55:53   [0x0-0x118118].org.pythonmac.unspecified.nsav_ws[5126]    File "/Users/luc/Dev/nelly_signe_avec_vous/nsav/nsav_mac/dist/nsav_ws.app/Contents/Resources/nsav_ws.py", line 2
25/10/12 16:55:53   [0x0-0x118118].org.pythonmac.unspecified.nsav_ws[5126]      
25/10/12 16:55:53   [0x0-0x118118].org.pythonmac.unspecified.nsav_ws[5126]      ^
25/10/12 16:55:53   [0x0-0x118118].org.pythonmac.unspecified.nsav_ws[5126]  SyntaxError: invalid syntax
25/10/12 16:55:53   nsav_ws[5126]   nsav_ws Error

I've entered an issue on py2app project page but I would appreciate if some of you have any ideas that may help to fix it.

here is the start of the program:

# -*- coding: utf-8 -*-

"""
    3 text 
    lines
"""

from dewapp.utils import is_exe
import sys, os, os.path, shutil

Solution

  • The problem was caused by windows line ending in the python code. Turning it into unix line ending fixed the issue. See https://bitbucket.org/ronaldoussoren/py2app/issue/70/generated-app-fails-due-to-syntax-error