[Pythonmac-SIG] $PYTHON and path variables?

Jack Jansen Jack.Jansen at cwi.nl
Fri Mar 19 04:00:50 EST 2004


On 17-mrt-04, at 2:33, tad wrote:

> I'm working with an application that calls the 2.2.3 PythonCoreCarbon
> library under OSX. I'm having some trouble sorting out how to set up 
> the
> $PYTHON variable and path strings.

Just to be exact, note that unix shell variables have nothing to do 
with this
whole process, MacPython-OS9 is completely unaware of Unix. But the
mechanism used by EditPythonPrefs has a similar effect to what editing
$PYTHONPATH has on unix.

> Currently, I have an alias in this main application's working folder
> that points to the PythonCoreCarbon library in the MacPython 2.2.3
> folder.
>
> For Python to find it's library files, I also had to copy :Lib and :Mac
> into the application's working folder. This works pretty well.
>
> I tried setting the $PYTHON variable via the "EditPythonPrefs" applet
> and noticed it puts this information in the Preferences file. I also
> noticed that these resources are included in the PythonCoreCarbon file
> as well, although they were not updated.

The trick you need to know is that EditPythonPrefs can work in two 
modes.
If you double-click it it will change the system-wide preferences. But 
if you
drop an application or applet on it what it will do is put some 
resources
in that application that override the system-wide preferences. The 
documentation
mentions this, but only for applets. It works just as fine for 
applications that
embed Python, however.

> Where is $PYTHON set for PythonCoreCarbon to find it? The Preference
> file?

It first looks for an override preferences resource in all open 
resource files.
That's usually the currently running application and the 
PythonCoreCarbon
resources. If it can't find anything there it looks in the preference 
file. If it
can't find anything there either it looks again in the currently open 
resource
files but now for a non-override preferences resource.

> Is there any way to set $PYTHON for PythonCoreCarbon without using a
> preferences file?

Yep. See above.
>
> Under what circumstances will PythonCoreCarbon use the path variable
> resources it owns?

That's used in step 3 above, when it can't find anything else.
--
Jack Jansen, <Jack.Jansen at cwi.nl>, http://www.cwi.nl/~jack
If I can't dance I don't want to be part of your revolution -- Emma 
Goldman




More information about the Pythonmac-SIG mailing list