On 9/26/06, Stephen Waterbury <[EMAIL PROTECTED]> wrote: > My app reads some of its core structures from a set of > RDF files. I have been keeping the RDF files in a directory > within the distribution, but it would be okay to have them in > my app's home directory, say ~/.my_app, when the package is > installed or when the user starts it up (the latter probably > making the most sense on systems that are designed to be > multi-user), but haven't yet got either way to work with > py2app. > > The new setuptools' pkg_resources API looked pretty good, > so I'm using it to pull data out of the RDF files with > 'resource_stream'. It works in my development environment > on Linux that has been configured with 'setup.py development', > and it also works on the Macintosh that way -- i.e., > running the script in the development environment, where it > can find the RDF files. But it doesn't work when I make > a package using py2app. > > (I fudged it on mswin by having the Innosetup > installer copy the files to the user's home directory > and then finding the home directory at startup.) > > py2app's '--resources' option seems like what I need, > but I can't seem to figure out the proper incantation, > because when the app starts up I immediately get an > error message that the files can't be found. > > I've attached the setup.py I'm using. Below is an > excerpt from my code that uses resource_stream, which > works fine when the files are in the place indicated. > > Any suggestions? (I did give the kb directory an > __init__.py, even though there are no modules in it, and > even tried putting the files into an __all__, but it had > no effect on py2app.) > > Thanks! > Steve > > ----------------------------------------------------- > kbres = {'pgef' : resource_stream('pangalactic', 'meta/kb/pgef.owl'), > 'pgef_meta' : resource_stream( > 'pangalactic', 'meta/kb/pgef_meta.owl'), > 'owl' : resource_stream('pangalactic', 'meta/kb/owl.rdf'), > 'rdf' : resource_stream('pangalactic', 'meta/kb/rdf.rdf'), > 'rdfs' : resource_stream('pangalactic', 'meta/kb/rdfs.rdf') > } > kb = KB(kbdata=kbres)
--packages=meta.kb -bob _______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig