How to create installer for mac osx

☆樱花仙子☆ 提交于 2019-12-11 06:01:22

问题


I am making an app in python, which is able to open different file types. This code in running fine on eclipse while passing filename which I want to open and configuration file as arguments respectively. Now I converted this into application by using py2app. So, the issue is how to deal with arguments, as different file types need to be open through app and this app also needs configuration file while processing. Is there any different methods available for making app which can be installed on mac osx.


回答1:


Have you had a look at py2app? Its pretty much py2exe for Mac OSX and creates a standalone app. You can handle the logger and configuration files pretty easily and keep your app nice and simple to distribute.

I usually store logger files in the users home directory as a hidden file - a lot of Mac OSX applications do this - i'm not sure if its officially the way to go but it works. The home directory is guaranteed to exist and you won't get permission errors like you would when you write to other random folders or to location inside the app bundle.

You can do this and keep your code cross platform buy opening files like this

import platform
import os

if platform.system() == 'Darwin': # We're on a mac
        # Store the saved rates in the users home dir - note the dot at the start
        # of the filename to keep the file hidden
        home = os.path.expanduser("~")
        filename = os.path.join(home, '.myHiddenLogger')

else: # We're on another platform, create whatever filename you were using before
        filename = 'myLogger'

As for the configuration file, this answer here tells you how to bundle a resource file in with you're app. If you want to write stuff to this configuration file and save it for next time, you'll have to store it as a hidden file like the logger - this will stop the app from crashing due to permission errors when it tried to write to a file inside the app bundle.



来源:https://stackoverflow.com/questions/19399253/how-to-create-installer-for-mac-osx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!