sys.prefix in COM

David Bolen db3l at fitlinxx.com
Tue Nov 27 19:19:44 EST 2001


sag at hydrosphere.com (Sue Giller) writes:

> I guess I can accept this, but how does the python path get built that 
> has all the other python things in it:  there are the various 
> python21\lib, ... things, but not any that should be found from the 
> .pth files.  I even tried calling site.py in my test com object but that 
> got the same results - a blank .prefix string.

I expect its loaded from the information in the registry
(HKLM\Software\Python\PythonCore\#.#\PythonPath), which is I believe
where the default sys.path is kept under Windows.  

> I hate the registry - hassles abound.  I would rather do anything else 
> including hard coding the path and forcing other users to use my 
> paths :)

Unfortunately, given the way in which COM objects may be invoked, the
registry really is the most appropriate (and guaranteed easy to
locate) source of information.

Note that you could also install your own sub-key beneath the
PythonPath key (that's how the win32 extensions do it).  I believe
that any sub-key can contain a default value which is automatically
appended to sys.path.

There's not much different from adding such a key to the registry
(just publish a .reg file for your users to use) and hardcoding a
path.

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



More information about the Python-list mailing list