[Pythonmac-SIG] Py2App and adding paths to sys.path
Christopher Barker
Chris.Barker at noaa.gov
Tue Jan 29 23:36:56 CET 2008
Kenneth Miller wrote:
> I do the same thing, can't you just include the Library code in
> the Bundle (py2app knows how to do this) and have it also search there?
Yes, I could, but then the entire package gets included, not just the
pyc files that I need -- not really a big deal, but it doesn't seem as
clean as it could be.
> As for the durus database, i've had problems with py2app bundling zope
> in the past.
I think I've got this figure out. The database itself is created with a
separate program. This program just reads it. However, it needs to have
all the modules that were used to create the database in order to
unpickle the objects in the database. py2app didn't include this module,
because it's imported on unpickling, and therefor never explicitly on an
import line.
Solution:
Force the inclusion of the module at hand.
the module I need is:
cameo.model.reactivity
However, I tried that with:
OPTIONS = {...
'packages': ['cameo.model'],
...
}
but what got put in the package was:
model
so that it would import as:
model.reactivity
so I did:
'packages': ['cameo'],
which did work, but then I got ALL of the cameo package, including both
.py and .pyc files, plus most of them were included in the site_packages
zip file anyway.
I'd think there'd be a way to specify a single module to be included in
the site_packages zip -- WITH the same package structure (in this case,
cameo.model. was there, with other modules, just not this one.
Anyway, the solution for now is just to put a:
import cameo.model.reactivity
line in one of the main modules of the app, so now py2app is finding it.
It seems there should be a more elegant way, though.
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
More information about the Pythonmac-SIG
mailing list