[Pythonmac-SIG] Trying to make an app

Bob Ippolito bob at redivi.com
Wed Oct 6 19:04:39 CEST 2004


On Oct 6, 2004, at 12:44 PM, Steven Palm wrote:

>
> On Oct 6, 2004, at 10:59 AM, Bob Ippolito wrote:
>> On Oct 6, 2004, at 11:39 AM, Steven Palm wrote:
>>>  Even though the `resource` files are where they are supposed to be, 
>>> I still get an error on running the program about recursion errors 
>>> and that it cannot find it's resource files.
>>
>> This is probably a bug in your program.. without any more information 
>> I can't help you.  The current directory of a py2app bundle is the 
>> Resources folder, so open('resources/mydatafile') will just work 
>> unless you do a chdir.
>
>  Hmmm...  Here is where it's looking... It initially does this when 
> one of the modules loads:
>
> # Where to find bitmaps etc
> p=sys.path[0]
> if os.path.isfile(p): # zip importer in action
>     p=os.path.dirname(p)
> resourcedirectory=os.path.abspath(os.path.join(p, 'resources'))
>
> And then later when trying  to load them it uses:
>
>  os.path.join(resourcedirectory, filename)
>
> So the difference in invocation between the bundlebuuilder-built  
> application bundle and the py2app-built application bundle is causing 
> a problem with finding the path where we are being run from, at least 
> in the way that BitPim is trying to find it in the above code. Anyway, 
> that's something for me to worry about. ;^)

Ok so don't do that!  Your application is trying to be too tricky.  
sys.path[0] is going to point to the os.path.dirname(sys.argv[0]), 
which is the bootstrap executable.  sys.path[1] is Resources, though.

If you want to see all stuff you need to know about look at 
examples/simple/ .. it is a program that prints out sys.executable, 
etc.

You start in the Resources folder, so just do:
resourcedirectory='resources'

-bob


More information about the Pythonmac-SIG mailing list