Sam Haberkorn
Sam Haberkorn

Reputation: 77

How to create a mac app from python files

I currently have a python application that runs perfectly from the CLI and when I run it from an IDE. I want to make it into an application that will launch in 1 click from any mac computer. (Like any desktop application). Ideally, I can send someone the file, they do a simple install, then the program works. I have tried using platypus (works great for 1 file programs) and other methods of bundling apps. But none of them seem to work as the program is kinda complex.

Program Requirements:

I would like to have an install process, where you click next a bunch of times and agree to things, but if this isn't possible I can live without it.

Any help is greatly appreciated!

Upvotes: 1

Views: 329

Answers (2)

Max00355
Max00355

Reputation: 867

I have used py2app for this in the past (https://py2app.readthedocs.io/en/latest/)

This article does a good job of explaining how to use it (https://www.metachris.com/2015/11/create-standalone-mac-os-x-applications-with-python-and-py2app/)

Basically you install the library and create a setup.py file that looks something like this

from setuptools import setup

APP = ['Sandwich.py']
APP_NAME = "SuperSandwich"
DATA_FILES = []

OPTIONS = {
    'argv_emulation': True,
    'iconfile': 'app.icns',
    'plist': {
        'CFBundleName': APP_NAME,
        'CFBundleDisplayName': APP_NAME,
        'CFBundleGetInfoString': "Making Sandwiches",
        'CFBundleIdentifier': "com.metachris.osx.sandwich",
        'CFBundleVersion': "0.1.0",
        'CFBundleShortVersionString': "0.1.0",
        'NSHumanReadableCopyright': u"Copyright © 2015, Chris Hager, All Rights Reserved"
    }
}

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

Upvotes: 0

Robert Kearns
Robert Kearns

Reputation: 1706

Use PyInstaller to build your package. I do not think they have an actual installer, but you could build your own GUI installer by using some CMD commands and something like tkinter.

Upvotes: 1

Related Questions