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
342 stars 36 forks source link

App works fine but damaged after download from web #465

Open CrazyNeil opened 2 years ago

CrazyNeil commented 2 years ago

I build the App on M1 Mac mini, and archive to dmg package by Mac disk utility. After upload the .dmg file to Amazon S3 and download it again, it shows dmg damaged and can't open error. I pretty sure .dmg file works fine without upload & download.

This error not happen if I build this App on Intel Mac, upload and download the .dmg works totally fine.

The whole build process are good and no errors come up on both M1 and Intel Mac.

I guess it's Signature problem on M1 Mac. Is that may caused by ttf font been added?

I read https://github.com/ronaldoussoren/py2app/issues/450 but still can't find a reason.

from setuptools import setup

APP = ['src/main.py']
APP_NAME = "AlphaBT"
DATA_FILES = ['src/factors', 'src/zh.ttf', 'src/filters', 'src/utils']
OPTIONS = {
    'iconfile': 'breil.ico',
    'plist': {
        'CFBundleName': APP_NAME,
        'CFBundleDisplayName': APP_NAME,
        'CFBundleGetInfoString': "alphaBT",
        'CFBundleIdentifier': "com.app.alpha.console",
        'CFBundleVersion': "1.0.0",
        'CFBundleShortVersionString': "1.0.0",
        'NSHumanReadableCopyright': "Copyright © 2022, MyApp Inc, All Rights Reserved",
        'LSPrefersPPC': True
    }
}

setup(
    app=APP,
    data_files=DATA_FILES,
    options={'py2app': OPTIONS},
    setup_requires=['py2app'],
)

Here is the pre-build output

(venv) ➜  alphaBT git:(main) ✗ python setup.py py2app -A                
running py2app
creating /Users/neil-mini/dev/alphaBT/build
creating /Users/neil-mini/dev/alphaBT/build/bdist.macosx-12-arm64
creating /Users/neil-mini/dev/alphaBT/build/bdist.macosx-12-arm64/python3.8-standalone
creating /Users/neil-mini/dev/alphaBT/build/bdist.macosx-12-arm64/python3.8-standalone/app
creating /Users/neil-mini/dev/alphaBT/build/bdist.macosx-12-arm64/python3.8-standalone/app/collect
creating /Users/neil-mini/dev/alphaBT/build/bdist.macosx-12-arm64/python3.8-standalone/app/temp
creating /Users/neil-mini/dev/alphaBT/dist
creating build/bdist.macosx-12-arm64/python3.8-standalone/app/lib-dynload
creating build/bdist.macosx-12-arm64/python3.8-standalone/app/Frameworks
Add paths for VENV /opt/homebrew/Cellar/python@3.8/3.8.13/Frameworks/Python.framework/Versions False
*** creating application bundle: AlphaBT ***
Copy '/Users/neil-mini/dev/alphaBT/venv/lib/python3.8/site-packages/py2app/apptemplate/prebuilt/main-arm64' -> '/Users/neil-mini/dev/alphaBT/dist/AlphaBT.app/Contents/MacOS/AlphaBT'
sign ['/Users/neil-mini/dev/alphaBT/dist/AlphaBT.app/Contents/MacOS/AlphaBT']
/Users/neil-mini/dev/alphaBT/dist/AlphaBT.app/Contents/MacOS/AlphaBT: replacing existing signature
/Users/neil-mini/dev/alphaBT/dist/AlphaBT.app/Contents/MacOS/AlphaBT: signed app bundle with Mach-O thin (arm64) [com.breil.alpha.console]
/Users/neil-mini/dev/alphaBT/dist/AlphaBT.app: replacing existing signature
/Users/neil-mini/dev/alphaBT/dist/AlphaBT.app: signed app bundle with Mach-O thin (arm64) [com.breil.alpha.console]
Done!

and launch in terminal by ./dist/MyApplication.app/Contents/MacOS/MyApplication shows no error

any one can help. thanks!

AdamHmouda commented 1 year ago

@ CrazyNeil hello , im having the same issue , my app work completely fine on my mac but when i compress and upload it to google drive or dropbox the app no longer works when i download it(I get the cant be opened error) . Note that i am trying to download it on the same mac where it worked before i uploaded it. Is there any fix for this ? or did you manage to fix the issue ?

hw2007 commented 6 months ago

I am having the same issue here. I did a bit of digging and found that once my app was downloaded from the web, it recieved a specific flag, called "com.apple.quarantine", which seems to tell macos that the app is not allowed to be opened.

You can check if your app has this flag by running "xattr [path to your app]". You can remove the flag by running "xattr -d com.apple.quarantine [path to your app]", and then the app will open just fine.

However it isn't exactly ideal to make your users type some random command into the terminal to make your app run. If anyone knows how to stop this flag from being added, please let me know!!!