{"id":15717134,"url":"https://github.com/prod3v3loper/python-mac-app","last_synced_at":"2025-03-30T21:20:29.179Z","repository":{"id":244077079,"uuid":"813988477","full_name":"prod3v3loper/python-mac-app","owner":"prod3v3loper","description":"🛠️ Developing macOS app","archived":false,"fork":false,"pushed_at":"2024-06-15T03:18:34.000Z","size":407,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-06T00:35:12.066Z","etag":null,"topics":["app","apple","application","dmg","mac","macos","macos-app","macos-application","macosx","python"],"latest_commit_sha":null,"homepage":"https://www.prod3v3loper.com","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/prod3v3loper.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-12T06:07:40.000Z","updated_at":"2024-09-15T16:33:57.000Z","dependencies_parsed_at":"2024-06-12T20:35:30.007Z","dependency_job_id":"ec3a98b8-843d-4109-b359-ad18fd989736","html_url":"https://github.com/prod3v3loper/python-mac-app","commit_stats":null,"previous_names":["prod3v3loper/python-mac-app"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prod3v3loper%2Fpython-mac-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prod3v3loper%2Fpython-mac-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prod3v3loper%2Fpython-mac-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prod3v3loper%2Fpython-mac-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/prod3v3loper","download_url":"https://codeload.github.com/prod3v3loper/python-mac-app/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246380004,"owners_count":20767794,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["app","apple","application","dmg","mac","macos","macos-app","macos-application","macosx","python"],"created_at":"2024-10-03T21:48:51.513Z","updated_at":"2025-03-30T21:20:29.146Z","avatar_url":"https://github.com/prod3v3loper.png","language":"Python","readme":"# Create from python code a macOS app\n\nCreate your own app for Apple macOS and more.\n\n# Needed\n\nWe need NodeJS and Python.\n\n## Install first\n\n- https://nodejs.org/\n- https://www.python.org/\n\n### Check it out\n\n- For `npm` get a look here: [Best practice](https://gist.github.com/prod3v3loper/979fd70264319e86ffff037996d3d7e7)\n- For `python` get a look here: [Best practice](https://gist.github.com/prod3v3loper/3be347af91e3eb4fb7fa23f899719c3c)\n\n## Then extensions\n\nFor NPM:\n\n```bash\n$ npm install -g create-dmg\n```\n\nFor python:\n\n```bash\n$ pip3 install pyinstaller\n```\n\nOR\n\n```bash\n$ pip3 install -r requirements.txt\n```\n\nYou can list your packages here:\n\n`requirements.txt`\n\n```plaintext\npyinstaller \n```\n\n## One file app\n\n![Mount](img/mount.png)\n\nCreate `example.py`\n\n```python\nimport tkinter as tk\n\ndef say_hello():\n    print(\"Hello, World!\")\n\napp = tk.Tk()\napp.title(\"Simple App\")\n\nhello_button = tk.Button(app, text=\"Say Hello\", command=say_hello)\nhello_button.pack(pady=20)\n\napp.mainloop()\n```\n\nAnd then packaging with PyInstaller:\n\n```bash\n$ pyinstaller --onefile --windowed example.py\n```\n\nAnd now create from dist folder your app:\n\n```bash\n$ create-dmg dist/example.app\n```\n\nYou see this message after creating without a code signing: \n\n```bash\n✖ No suitable code signing identity found\n```\n\nRun create-dmg with the --no-skip-checks option to skip code signing:\n\n```bash\ncreate-dmg dist/example.app --no-skip-checks\n```\n\n## Free options for code signing\n\nHowever, there are also some free options if you just want to test apps on your own device or do not plan on official distribution via the App Store.\n\nYou can create a free Apple Developer account to test apps on your own devices. This has some limitations, such as the need to renew the certificate every seven days, but it is sufficient for basic testing.\n\n- Download Xcode from the Mac App Store.\n- Open Xcode and go to Xcode \u003e Preferences \u003e Accounts.\n- Go to the project's \"Signing \u0026 Capabilities\".\n- Select your Apple ID profile from the team drop-down menu.\n- Xcode automatically creates a signed certificate for you if you use the free developer account.\n\n```bash\ncodesign --deep --force --verify --verbose --sign \"Developer ID Application: Your Name (Team ID)\" dist/example.app\n```\n\nAfter codesign\n\n```bash\n$ create-dmg dist/example.app\n```\n\n## Sign and distribute apps with a paid developer account\n\nIf you want code signing, create a [Apple Developer Account](https://developer.apple.com/) and join **Apple Developer Program** currently costs $99 per year.\n\n### Create certificates and provisioning profiles:\n\nOnce you're a member, you can create certificates and provisioning profiles needed to sign and publish your apps.\n\n- Sign in to the Apple Developer Account.\n- Go to the Certificates, IDs \u0026 Profiles section.\n- Create a Developer ID Application certificate for signing apps outside of the Mac App Store.\n\nSign the app:\n\nAfter you've created and downloaded the certificate, open the Keychain Access app on your Mac and import the certificate.\n\n```bash\n$ codesign --deep --force --verify --verbose --sign \"Developer ID Application: Your Name (Team ID)\" dist/example.app\n```\n\nAfter codesign\n\n```bash\n$ create-dmg dist/example.app\n```\n\nNotes:\n\n- **Using your private Apple ID**: When you use your private Apple ID, all apps and certificates are connected to your personal information. \n\n\u003e If you don't want this, you can create a separate Apple ID just for development.\n\n- **Team ID**: The Team ID is a unique identifier assigned to you when you join the Apple Developer Program. You can find this in your Apple Developer Account.\n\n## Full Project\n\nDo you have more than one file or multiple files for your program?\n\n```\npython-mac-app/\n├── main.py\n├── module1.py\n├── module2.py\n├── python-mac-app.spec\n├── assets/\n│   ├── image.png\n│   └── data.json\n└── ...\n```\n\nCreate the `python-mac-app.spec`\n\n```\n# -*- mode: python ; coding: utf-8 -*-\n\nblock_cipher = None\n\na = Analysis(\n    ['main.py'],\n    pathex=['./python-mac-app'],\n    binaries=[],\n    datas=[\n        ('assets/image.png', 'assets'),\n        ('assets/data.json', 'assets')\n    ],\n    hiddenimports=[],\n    hookspath=[],\n    runtime_hooks=[],\n    excludes=[],\n    win_no_prefer_redirects=False,\n    win_private_assemblies=False,\n    cipher=block_cipher,\n    noarchive=False\n)\n\npyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)\n\nexe = EXE(\n    pyz,\n    a.scripts,\n    [],\n    exclude_binaries=True,\n    name='main',\n    debug=False,\n    bootloader_ignore_signals=False,\n    strip=False,\n    upx=True,\n    console=False\n)\n\ncoll = COLLECT(\n    exe,\n    a.binaries,\n    a.zipfiles,\n    a.datas,\n    strip=False,\n    upx=True,\n    upx_exclude=[],\n    name='main'\n)\n```\n\nAnd now use the spec file to create your app:\n\n```bash\n$ pyinstaller python-mac-app.spec\n```\n\nAnd then create from dist folder your app:\n\n```bash\n$ create-dmg dist/python-mac-app.app\n```\n\n# ISSUE\n\nPlease use the issue tab to request a:\n\n* Bug\n* Feature\n\nChoose template and report a bug or feature you want [issues](https://github.com/prod3v3loper/python-mac-app/issues).\n\n# CONTRIBUTE\n\nPlease read the [contributing](https://github.com/prod3v3loper/python-mac-app/blob/main/.github/CONTRIBUTING.md) to contribute.\n\n# VULNERABILITY\n\nPlease use the Security section for privately reporting a [vulnerability](https://github.com/prod3v3loper/python-mac-app/SECURITY.md).\n\n# AUTHOR\n\n[prod3v3loper](https://www.prod3v3loper.com)\n\n# License\n\n[MIT](https://github.com/prod3v3loper/python-mac-app/blob/main/LICENSE)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprod3v3loper%2Fpython-mac-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprod3v3loper%2Fpython-mac-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprod3v3loper%2Fpython-mac-app/lists"}