xml.dom.minidom + py2exe

Martin von Loewis loewis at informatik.hu-berlin.de
Wed Jul 18 10:49:35 EDT 2001


"Thomas Heller" <thomas.heller at ion-tof.com> writes:

> > It looks like the XML module is using som kind of dynamic loader (like Pmw
> > does), and these modules naturally escape py2exe.
> 
> This is indeed the case:
> 
> C:\sf\py2exe\tests>c:\python20\python.exe
> Python 2.0 (#8, Apr 25 2001, 22:09:02) [MSC 32 bit (Intel)] on win32
> Type "copyright", "credits" or "license" for more information.
> >>> import xml
> >>> xml
> <module '_xmlplus' from 'c:\python20\_xmlplus\__init__.pyc'>

_xmlplus is provided by PyXML, so it is only available if PyXML is
installed. OTOH, this was not the problem for py2exe: It (correctly)
detected that _xmlplus could not be found, this is triggered by
xml/__init__.py's

try:
    import _xmlplus
except ImportError:
    pass
else:
    ...

Here is a clear import statement for _xmlplus, but it is no problem if
that fails. What did cause the problem is the code

default_parser_list = ["xml.sax.expatreader"]
...
    for parser_name in parser_list + default_parser_list:
        try:
            return _create_parser(parser_name)
        except ImportError,e:
            import sys
...
    def _create_parser(parser_name):
        drv_module = __import__(parser_name,{},{},['create_parser'])
        return drv_module.create_parser()

in xml/sax/__init__.py. So for freezing (py2exeing?) XML applications,
you have to give xml.sax.expatreader as a 'static' module, and
perhaps any additional parsers you may want to use.

Regards,
Martin



More information about the Python-list mailing list