McMillan's Installer problem with win32com
Gordon McMillan
gmcm at hypernet.com
Wed Aug 2 08:56:02 EDT 2000
Robin Becker wrote:
[Mark's code that explicitly resolves "pywintypes" to "PyWinTypes15.dll"]
>In article <eKLh5.18634$4p3.149948 at news-server.bigpond.net.au>, Mark
>Hammond <MarkH at ActiveState.com> writes
[someone]
>>> Where should i write this code??
>>The intent of this code is to make "pythoncom" and "pywintypes"
>>available as modules, given their funny names, and sans their
>>registration in the Windows registry. So this code should appear
>>anywhere it will be executed before the first real import of pythoncom
>>or pywintypes.
>a packaged python app surely needs a site.py which is a good place to
>put such hacks.
No. If your site.py extends your path, then the Installer will use that
extended path to search for things. But it won't package up your site.py.
The original poster should just put this code at the top of his main
script. This is probably the easiest way to get around lots of import hacks
(or cases where C code imports modules directly without going through the
builtin __import__). Just import the right thing first; since the module
will already be in sys.modules, most import hacks won't have a chance to do
their thing.
For example, to use shelve, you need to
import dbhash
import string
import copy_reg
before the
import shelve
because shelve imports anydbm (which uses __import__ to get dbhash or one
of it's alternatives), and cPickle (which does C-level imports of string
and copy_reg).
-Gordon
More information about the Python-list
mailing list