Found a problem and solution in many hours. It turns out that other people had similar problems, and their articles were very useful:
http://b.atcg.us/blog/2010/04/13/py2app-hell-the-first.html
http://www.vijayp.ca/blog/?p=62
In the event that someone else is having a problem, this particular problem was caused by the fact that the Python infrastructure was not included in the application. You can confirm this by right-clicking your application to view the contents of the package, and then go to Contents / Frameworks /. If Python.framework does not exist, it should be.
Be sure to download Python - My first problem was that Apple built the Python package. Do not use this. You need to install your own version of python. Go to http://www.python.org/download/releases/ , find the version (I'm stuck with 2.6), download gzip (not the mac package) and install with the following if you are using Snow Leopard:
./configure --enable-framework MACOSX_DEPLOYMENT_TARGET=10.6 --with-universal-archs=intel --enable-universalsdk=/ make sudo make install
Customize paths, install packages . Here you need to customize your paths to make sure that you are using your own version. From here I reinstalled the following packages - this turned out to be a nightmare of dependency, so I also include version numbers:
- py2app 0.5.2
- macholib 1.3
- modulegraph.8.0
If these packages really worked, you can create and run your application now. Unfortunately, they do not. Iโll work a bit with bugs and my hacked solutions, but first you need to create some settings in the build file.
First, the setup.py file should slightly resemble the following:
setup.py
from setuptools import setup APP = ['Game.py'] DATA_FILES = ['data'] OPTIONS = { "argv_emulation": False, "compressed" : True, "optimize":2, "iconfile":'data/game.icns', } setup( app=APP, data_files=DATA_FILES, options={'py2app': OPTIONS}, )
then for extra security I use a shell script to call this.
build.sh
#
Running build.sh should compile the application. If it does not compile, I have good news - it is not your fault. Due to library crashes, you may encounter some (or all) of the following:
Potential Issues If the script build fails, trace scan for some of the following keywords:
pygame not found - main path issue in py2app. Add ...
sys.path.insert(0, os.path.join(os.getcwd(), 'lib', 'python2.6','lib-dynload')) ## Added to fix dynlib bug
after the import statements in boot_app.py in the py2app folder.
pythonNone . This is similar to a bug in the macho package where it cannot determine the version number of your python assembly. To solve this problem, I added the following lines to build_app.py in py2app.
## Add these two lines... if not info["version"]: info["version"] = "2.6" ## Before this line. (line 941 in method copy_python_framework() at time of writing) pydir = 'python%s'%(info['version'])
There is no such file or directory ... Python.framework / [lib | include] - py2app just looks for directories that exist deeper in the file system tree. Go to the Python.framework directory and add a symlink ...
cd /Library/Frameworks/Python.framework sudo ln -s Versions/Current/include/ include sudo ln -s Versions/Current/lib lib
That should do it! . These steps created a compiled application that runs on other intel computers.