I'm trying to learn pygame, And I found the best way to have the finished game (assuming python 2.6 and pygame installed) is to have an applescript that runs it, and saved as an app bundle (with python files etc. inside the bundle). Here is what I have:
do shell script "cd " & the quoted form of the POSIX path of (path to me) & "Contents/Resources/files\n/usr/local/bin/pythonw creeps.py"
I need the cd command because the python code uses the relative path to get at its images folder. The files directory is where my python files are, and subdirectories such as 'images'. I think having an app file like this is a lot better than a lone .py file, which could opened by anything by default. Do you think this is a good way to bundle a python script? Also, would I be able to just bundle pygame along with it instead of requiring that to be installed too? Thanks.
Also, now, the script runs and python is also running, each with their own dock icons. Could I make it so that the script just executes and quits, leaving python running? Thanks.
I changed the script to:
do shell script ". ~/.bash_profile\npythonw2.6 " & the quoted form of the POSIX path of (path to me) & "Contents/Resources/files/creeps.py"
That way, it searches the path instead of only looking in /usr/local/bin. ~/.bash_profile
needs to be called to set and export the $PATH for python (which it automatically adds in .bash_profile
when you install python).
A problem is that the script app bundle 'isn't responding' while its running, but the Python app is fine. How can I make the script app bundle get python going and then quit and leave python there by itself? And couldn't I just put the pygame module inside the bundle? Its only ~9MB.