ronaldoussoren / py2app

py2app is a Python setuptools command which will allow you to make standalone Mac OS X application bundles and plugins from Python scripts.
Other
345 stars 36 forks source link

argv gets mangled #227

Closed ronaldoussoren closed 7 years ago

ronaldoussoren commented 7 years ago

Original report by René Steetskamp (Bitbucket: otech-nl, GitHub: otech-nl).


Thanks for py2app. It extends my customer base with Mac users :)

I have an app that I last generated succesfully in december 2016. Generating still works fine, but when I drag an Excel file on my app, the filename gets mangled:

argv: ['/Users/steets/src/tinker.py', '-psn_0_3773337']

This happens both in alias and in dist mode.

My setup.py:

setup(
    app=['tinker.py'],
    data_files=[('', ['static'])],
    options=dict(
        py2app=dict(
            iconfile='static/icon.icns',
            argv_emulation=True,
            plist=dict(
                CFBundleName='Tinker',
                CFBundleDisplayName='Tinker',
                CFBundleGetInfoString='Tinker',
                CFBundleIdentifier='nl.otech.tinker',
                CFBundleVersion=VERSION,
                CFBundleShortVersionString=VERSION,
                NSHumanReadableCopyright=u'Copyright © 2017, otech.nl, All Rights Reserved',
        ))),
    setup_requires=['py2app']
)

I noticed in py2app/bootstrap/argv_emulation.py:242 that py2app is supposed to remove these 'funny -psn_xxx_xxx arguments', but this does not seem to happen. The script runs fine from the command line (without py2app).

System is Python version 2.7.13 (but also tested on 3.6 with the same results) on Mac OS El Capitan 10.11.6 (Platform: darwin) with the latest py2app (requirements.txt: hg+https://bitbucket.org/ronaldoussoren/py2app) but also tried from pypi with the same result.

I have noticed issue #222 but I still can't get it to work.

Any help would be greatly appreciated!

ronaldoussoren commented 7 years ago

Original comment by René Steetskamp (Bitbucket: otech-nl, GitHub: otech-nl).


It turns out that the condition in bootstrap/argv_emulation.py:282 is False, so argv emulation is not even run. When I change the condition to always return True, my problem goes away.

The question now remains where _PY2APPLAUNCHED in env is set.

ronaldoussoren commented 7 years ago

Original comment by René Steetskamp (Bitbucket: otech-nl, GitHub: otech-nl).


This turns out to be in apptemplate/src/main.c:1211 (which depends on variable is_app_bundle which is set around line 1184).

I am no stranger to C, but the logic here is too deep for me. Any ideas?

ronaldoussoren commented 7 years ago

Original comment by Ronald Oussoren (Bitbucket: ronaldoussoren, GitHub: ronaldoussoren).


This will be fixed in the next release, the code to activate the argv_emulator code was broken due to an unrelated change (see #222 for more information).

ronaldoussoren commented 7 years ago

Original comment by René Steetskamp (Bitbucket: otech-nl, GitHub: otech-nl).


Thanks for your response. Until the next release I'll use the workaround.

ronaldoussoren commented 7 years ago

Original comment by Ronald Oussoren (Bitbucket: ronaldoussoren, GitHub: ronaldoussoren).


I've just pushed out py2app 0.14 that fixes this issue.

ronaldoussoren commented 7 years ago

Original comment by René Steetskamp (Bitbucket: otech-nl, GitHub: otech-nl).


Thanks for your quick work.

Have a nice day!