[Pythonmac-SIG] PYTHONPATH in Mac OS X App
Drew McCormack
drewmccormack at mac.com
Wed Sep 17 14:41:15 EDT 2003
I am tackling my first attempt to create a python interface to a C++
library, using SWIG.
I have a couple of problems. The first is that I am not sure how to
create a shared object (eg pplot.so). I can work around this, but if
someone can tell me, I'd appreciate it.
The second, more serious problem, occurs when I try to embed python in
a Cocoa app. I have everything setup OK so that I can run a python
script by passing it as a string to Py_RunSimpleString. But I am having
trouble loading my C++ library. To do this I need to load the module
'pplot.py'. If I put this somewhere in PYTHONPATH, there is no problem.
But I want to include pplot.py in my App bundle, and it doesn't get
found there if I write 'import pplot' in my embedded script, because
pplot.py is not in PYTHONPATH.
My question is, what is the best way to load pplot.py from a directory
in my app bundle? I would rather not hard code a path, because I want
to be able to install my app anywhere. So I would prefer a solution
that allows me to set the path to pplot.py at run time.
I can think of diverse solutions, but I don't know which would be the
best approach. I need the council of a more experienced Python
programmer.
Drew
----------------------------------
Dr. Drew McCormack
Trade Strategist (www.trade-strategist.com)
Stock Market strategy design platform for Mac OS X.
More information about the Pythonmac-SIG
mailing list