如何从python包创建osx应用程序/dmg? [英] How do you create an osx application/dmg from a python package?

查看:720
本文介绍了如何从python包创建osx应用程序/dmg?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从python包创建一个Mac osx应用程序,然后将其放入磁盘映像中.

I want to create a mac osx application from python package and then put it in a disk image.

因为我从软件包中加载了一些资源,所以该软件包应该驻留在zip文件中.

Because I load some resources out of the package, the package should not reside in a zip file.

生成的磁盘映像应显示背景图片,以将其拖到此处->应用程序"进行安装.

The resulting disk image should display the background picture to "drag here -> applications" for installation.

推荐答案

我不知道正确的方法,但是这种手动方法是我用于似乎已适当执行的​​简单脚本的方法.

I don't know the correct way to do it, but this manual method is the approach I've used for simple scripts which seems to have preformed suitably.

我将假定无论我在哪个目录中,程序的Python文件都在相对的src/目录中,并且我要执行的文件(具有适当的shebang和execute权限)已命名为main.py.

I'll assume that whatever directory I'm in, the Python files for my program are in the relative src/ directory, and that the file I want to execute (which has the proper shebang and execute permissions) is named main.py.


$ mkdir -p MyApplication.app/Contents/MacOS
$ mv src/* MyApplication.app/Contents/MacOS
$ cd MyApplication.app/Contents/MacOS
$ mv main.py MyApplication

目前,我们已经有了一个应用程序捆绑包,据我所知,该捆绑包可以在安装了Python的任何Mac OS系统上运行(我认为默认情况下已安装).它没有图标或其他任何东西,需要在程序包中添加更多元数据,这对我来说是不必要的,我也不熟悉.

At this point we have an application bundle which, as far as I know, should work on any Mac OS system with Python installed (which I think it has by default). It doesn't have an icon or anything, that requires adding some more metadata to the package which is unnecessary for my purposes and I'm not familiar with.

创建拖放安装程序非常简单.使用磁盘工具创建一个新磁盘映像,其大小大约与存储应用程序所需的大小相同.打开它,将您的应用程序和别名/Applications复制到驱动器,然后使用查看选项"将它们放置在所需的位置.

To create the drag-and-drop installer is quite simple. Use Disk Utility to create a New Disk Image of approximately the size you require to store your application. Open it up, copy your application and an alias of /Applications to the drive, then use View Options to position them as you want.

拖放消息只是磁盘映像的背景,您也可以在查看选项"中指定.我以前没有做过,但是我假设在您选择的编辑器中鞭打图像后,您可以将其复制过来,将其设置为背景,然后使用chflags hidden来防止其混乱窗口.

The drag-and-drop message is just a background of the disk image, which you can also specify in View Options. I haven't done it before, but I'd assume that after you whip up an image in your editor of choice you could copy it over, set it as the background and then use chflags hidden to prevent it from cluttering up your nice window.

我知道这些不是最清晰,最简单或最详细的说明,但我希望有人会发现它们有用.

I know these aren't the clearest, simplest or most detailed instructions out there, but I hope somebody may find them useful.

这篇关于如何从python包创建osx应用程序/dmg?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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