如何为Mac OSX创建安装程序 [英] How to create installer for mac osx

查看:150
本文介绍了如何为Mac OSX创建安装程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用python开发一个应用程序,该应用程序可以打开不同的文件类型.这段代码在eclipse上运行良好,同时传递了我想打开的文件名和分别作为参数的配置文件.现在,我使用py2app将其转换为应用程序.因此,问题在于如何处理参数,因为需要通过应用程序打开不同的文件类型,并且此应用程序在处理时还需要配置文件.可以在Mac osx上安装制作应用程序的方法有哪些.

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.

推荐答案

您看看 py2app ?它几乎适用于Mac OSX的py2exe,并创建了一个独立的应用程序.您可以轻松地处理记录器和配置文件,并使应用程序保持美观和易于分发.

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.

我通常将记录器文件作为隐藏文件存储在用户的主目录中-许多Mac OSX应用程序都执行此操作-我不确定它是否正式可用,但是否可行.肯定存在主目录,并且不会像写入其他随机文件夹或应用程序捆绑包内的位置那样出现权限错误.

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.

这篇关于如何为Mac OSX创建安装程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆