Please bear with me for seriously newbie (lack of) knowledge. I've trawled though previous answers on SO and made some progress, but I'm now really stuck and would really appreciate some help.
I have a working python (pygame) programme which includes images and sounds saved to the same folder as the .py file. I'm trying to turn it into an app with py2app.
I've written the setup.py file, and it seems to work fine. When I try to run the app it creates within the '/build/' directory, I just get an error in a popup window which reads '[appname] Error'. When I open the console, the relevant error message seems to be:
" 30/03/2013 08:47:02.425 com.apple.launchd.peruser.501[192]: ([0x0-0x1de2de1].org.pythonmac.unspecified.CookieMemory[17113]) Exited with code: 255"
I think my problem may be that the app is not able to access the data files (images, sounds) properly. I can see them there within the "Contents/Resources" folder. In order to get the image and sound files included within the app as Resources, I created a new folder (called "Memory") for them (within the /Users) directory - i.e. the same directory as where the setup.py and my .py program are. And I included a couple of lines of code at the start of the .py program to tell it to look in there for the image and sound files… since the .py program originally loaded them directly from the same folder in which it was saved. The .py program is happy with that change - when I run it directly via IDLE or the Terminal - but the app is not...
Here's my setup.py file:
from setuptools import setup
APP = ['CookieMemory.py']
DATA_FILES = ['Memory']
OPTIONS = {'iconfile':'cookieIcon.icns','argv_emulation': True}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
Here is the addition I made to the .py file:
import os,sys
currentFilePath=sys.argv[0]
currentDir=os.path.dirname(currentFilePath)
os.chdir(os.path.join(currentDir,"Memory"))
Any suggestions please?