I want to create a mac osx application from python package and then put it in a disk image.
我想从python包创建一个mac osx应用程序,然后将其放入磁盘映像中。
Because I load some resources out of the package, the package should not reside in a zip file.
因为我从包中加载了一些资源,所以包不应该驻留在zip文件中。
The resulting disk image should display the background picture to "drag here -> applications" for installation.
生成的磁盘映像应显示背景图片以“拖动此处 - >应用程序”进行安装。
1 个解决方案
#1
8
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.
我不知道正确的方法,但这种手动方法是我用于简单脚本的方法,似乎已经适当地执行。
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
.
我假设我所在的目录中,我的程序的Python文件位于相对的src /目录中,而我想要执行的文件(具有正确的shebang和执行权限)名为main.py.
$ mkdir -p MyApplication.app/Contents/MacOS $ mv src/* MyApplication.app/Contents/MacOS $ cd MyApplication.app/Contents/MacOS $ mv main.py MyApplication
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.
此时我们有一个应用程序包,据我所知,它应该适用于任何安装了Python的Mac OS系统(默认情况下我认为它)。它没有图标或任何东西,需要在包中添加更多元数据,这对我的目的是不必要的,我不熟悉。
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.
创建拖放安装程序非常简单。使用“磁盘工具”创建大小与存储应用程序所需大小相同的新磁盘映像。打开它,将您的应用程序和/ Applications的别名复制到驱动器,然后使用视图选项根据需要定位它们。
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.
拖放消息只是磁盘映像的背景,您也可以在“视图选项”中指定。我之前没有这样做过,但我假设你在你选择的编辑器中掀起一个图像后你可以复制它,将它设置为背景然后使用隐藏的chflags来防止它弄乱你漂亮的窗口。
I know these aren't the clearest, simplest or most detailed instructions out there, but I hope somebody may find them useful.
我知道这些并不是最清晰,最简单或最详细的说明,但我希望有人可能会发现它们很有用。
#1
8
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.
我不知道正确的方法,但这种手动方法是我用于简单脚本的方法,似乎已经适当地执行。
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
.
我假设我所在的目录中,我的程序的Python文件位于相对的src /目录中,而我想要执行的文件(具有正确的shebang和执行权限)名为main.py.
$ mkdir -p MyApplication.app/Contents/MacOS $ mv src/* MyApplication.app/Contents/MacOS $ cd MyApplication.app/Contents/MacOS $ mv main.py MyApplication
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.
此时我们有一个应用程序包,据我所知,它应该适用于任何安装了Python的Mac OS系统(默认情况下我认为它)。它没有图标或任何东西,需要在包中添加更多元数据,这对我的目的是不必要的,我不熟悉。
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.
创建拖放安装程序非常简单。使用“磁盘工具”创建大小与存储应用程序所需大小相同的新磁盘映像。打开它,将您的应用程序和/ Applications的别名复制到驱动器,然后使用视图选项根据需要定位它们。
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.
拖放消息只是磁盘映像的背景,您也可以在“视图选项”中指定。我之前没有这样做过,但我假设你在你选择的编辑器中掀起一个图像后你可以复制它,将它设置为背景然后使用隐藏的chflags来防止它弄乱你漂亮的窗口。
I know these aren't the clearest, simplest or most detailed instructions out there, but I hope somebody may find them useful.
我知道这些并不是最清晰,最简单或最详细的说明,但我希望有人可能会发现它们很有用。