[Pythonmac-SIG] py2app help requested: data files (and where are the examples?)

Bob Ippolito bob at redivi.com
Tue Jan 24 00:59:22 CET 2006


On Jan 23, 2006, at 3:24 PM, Russell E. Owen wrote:

> I'm trying to convert from bundlebuilder to py2app to build my
> application.
>
> I installed py2app 0.2 using the installer at
> <http://pythonmac.org/packages/>. I have both a working bundlebuilder
> script and a working py2exe script to start from.
>
> The main question: how do get my data files into the bundle? E.g. I  
> want
> all (non-code) files in <approot>/foo/bar/ copied into <app
> bundle>/Contents/Resources/foo/bar/ for directories.
>
> For my py2exe script I specify a data_files argument to setup,  
> supplying
> a list of (source dir, dest dir) pairs. I tried that on Mac (with the
> paths suitably modified)

That's not supposed to work.  If you read the docs for py2exe, it's  
supposed to be (dest_dir, [sources...]).  py2app emulates most of  
py2exe's documented features, but it's apparently not bug-for-bug  
compatible ;)

> and I get an error:
> DistutilsFileError: can't copy 'C': doesn't exist or not a regular  
> file

That's because you passed a string where a list of strings is  
supposed to go.  Unfortunately, strings in Python act like list of  
single-character strings.

> Here are the elements of data_files:
> ('/Users/rowen/TUIRoot/TUI/Help', 'Contents/Resources/TUI/Help')
> ('/Users/rowen/TUIRoot/TUI/Scripts', 'Contents/Resources/TUI/Scripts')
> ('/Users/rowen/TUIRoot/TUI/Sounds', 'Contents/Resources/TUI/Sounds')
> ('/Users/rowen/TUIRoot/RO/Bitmaps', 'Contents/Resources/RO/Bitmaps')
> ('/Library/Tcl/snack2.2',
> 'Contents/Frameworks/Tcl.Framework/Resources/snack2.2')
>
> I also tried truncating data_files to just the first element of this
> list, with no difference.

data_files is incorrect.  I'm not sure why what you have works  
elsewhere, but it's not documented to work.  data_files needs to look  
like this:

data_files=[
	(destination_dir, [srcfile, ...]),
]

What you have is not only the wrong kinds of data, but in the wrong  
order...  I'm quite surprised that worked in py2exe, but maybe  
bundlebuilder used a different syntax for data_files?

> Also, as an aside, where are the examples installed? I've searched for
> them in vain. (I also tried inspecting the py2app installer  
> package, but
> wasn't sure what to do with the .pax file.)

This is actually documented:
http://undefined.org/python/py2app.html

As far as introspecting an installer pkg, you'd want to use lsbom on  
the bom (bill of materials) file.

-bob



More information about the Pythonmac-SIG mailing list