[Pythonmac-SIG] Py2App and adding paths to sys.path
Christopher Barker
Chris.Barker at noaa.gov
Tue Jan 29 20:55:05 CET 2008
Hi all,
I'm trying to bundle up a pretty complicated app.
During the app's initialization, a path is added to sys.path, so that it
can see the app's "library" code:
app_root = os.path.dirname(os.path.dirname(os.path.abspath(
os.path.realpath(__file__))))
app_lib_dir = os.path.join(app_root, "lib")
sys.path.insert(0, app_lib_dir)
So it looks to see where the initialization file lives, then it adds the
"lib" dir relative to that.
This clearly won't work right with py2app.
My solution, so far, is to wrap the above in a "if sys.frozen is not
None" call, so it doesn't run. Then, I added that path in the top of my
setup.py, so py2app can find all the modules it needs.
This works mostly OK with the app bundle, but doesn't work when I try to
run in alias mode, which I'd really like to be able to do.
Also, while it mostly works with the app bundle, I am having some
trouble with the durus database, which uses pickles -- I think it's
having trouble finding the modules it needs to unpickle some stuff. I'll
need to dig into this deeper, but it seems maybe I'm just not doing this
right.
Suggestions welcome.
-CHB
--
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