From: Stpehen D. <ste...@ra...> - 2005-06-22 10:18:08
|
I've been trying to do what I thought would be a simple task, but all the docs and google have failed me so far :-) I have a program which uses the sax parser classes from xml.sax, however every time I run py2exe I get errors about xml.sax.saxlib being not found. The dist directory includes pyexpat.pyd so something knows that I'm using the expat parser material, but the executable just doesn't work. libary.zip doesn't appear to contain xml/sax/saxlib although it does contain xml/sax/saxutils; I'm confused. I've read about the need to do stuff with extension modules not being on by default, but I'm not sure whether pyexpat counts as one of those, and I don't want to be building it from source anyway. The same behaviour happens with both python 2.3 and 2.4 - am I missing something really obvious about how to make this work? -- Stephen Dicks Rawflow Ltd |
From: Thomas H. <th...@py...> - 2005-06-22 11:17:56
|
Stpehen Dicks <ste...@ra...> writes: > I've been trying to do what I thought would be a simple task, but all > the docs and google have failed me so far :-) > > I have a program which uses the sax parser classes from xml.sax, > however every time I run py2exe I get errors about xml.sax.saxlib > being not found. The dist directory includes pyexpat.pyd so something > knows that I'm using the expat parser material, but the executable > just doesn't work. libary.zip doesn't appear to contain xml/sax/saxlib > although it does contain xml/sax/saxutils; I'm confused. Ok. > I've read about the need to do stuff with extension modules not being > on by default, but I'm not sure whether pyexpat counts as one of > those, and I don't want to be building it from source anyway. I don't understand what you are talking about here ;-) > The same behaviour happens with both python 2.3 and 2.4 - am I missing > something really obvious about how to make this work? You should try the '-p' command line switch to specify complete packages to include: setup.py py2exe -p xml.sax or setup.py py2exe -p xml Thomas |
From: Stephen D. <ste...@ra...> - 2005-06-22 12:00:42
|
Thomas Heller wrote: >Stpehen Dicks <ste...@ra...> writes: > > > >>I've been trying to do what I thought would be a simple task, but all >>the docs and google have failed me so far :-) >> >>I have a program which uses the sax parser classes from xml.sax, >>however every time I run py2exe I get errors about xml.sax.saxlib >>being not found. The dist directory includes pyexpat.pyd so something >>knows that I'm using the expat parser material, but the executable >>just doesn't work. libary.zip doesn't appear to contain xml/sax/saxlib >>although it does contain xml/sax/saxutils; I'm confused. >> >> > >Ok. > >the py2exe docs talk about extension modules not being dragged in by default. I'm not sure whether pyexpat counts as an extension module. > > > You should try the '-p' command line switch to specify complete packages > >to include: > > setup.py py2exe -p xml.sax >or > setup.py py2exe -p xml > > I've tried this (and many other variations on the same theme via parameters to the setup() call) and it still has no effect. -- Steve Dicks Rawflow Ltd |
From: Michael F. <mi...@pc...> - 2005-06-22 13:36:21
|
Stephen Dicks wrote: > [snip..] > >> the py2exe docs talk about extension modules not being dragged in by >> default. I'm not sure whether pyexpat counts as an extension module. >> >> >> You should try the '-p' command line switch to specify complete packages >> >> to include: >> >> setup.py py2exe -p xml.sax >> or >> setup.py py2exe -p xml >> >> > I've tried this (and many other variations on the same theme via > parameters to the setup() call) and it still has no effect. > I *swear* I already replied to this ! Anyway - I have a *clue* : >>> import xml.sax.saxlib >>> xml.sax.saxlib.__file__ 'C:\\Python23\\lib\\site-packages\\_xmlplus\\sax\\saxlib.pyc' >>> xml.sax.saxlib is *actually* something else. This reminds me of the magic that the windows extensions do - there might be some help on the wiki. I can't actually see the magic in the __init__.py files - but I haven't been through with a fine tooth comb. Including _xmlplus.sax as a package might work. Regards, Fuzzyman http://www.voidspace.org.uk/python (when it works :-( > -- > Steve Dicks > Rawflow Ltd > > > ------------------------------------------------------- > SF.Net email is sponsored by: Discover Easy Linux Migration Strategies > from IBM. Find simple to follow Roadmaps, straightforward articles, > informative Webcasts and more! Get everything you need to get up to > speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click > _______________________________________________ > Py2exe-users mailing list > Py2...@li... > https://lists.sourceforge.net/lists/listinfo/py2exe-users > > > |
From: Michael F. <mi...@pc...> - 2005-06-22 13:55:17
|
Michael Foord wrote: > [snip..] > >>> import xml.sax.saxlib > >>> xml.sax.saxlib.__file__ > 'C:\\Python23\\lib\\site-packages\\_xmlplus\\sax\\saxlib.pyc' > >>> > > xml.sax.saxlib is *actually* something else. This reminds me of the > magic that the windows extensions do - there might be some help on the > wiki. I can't actually see the magic in the __init__.py files - but I > haven't been through with a fine tooth comb. > > Including _xmlplus.sax as a package might work. > Stephen , Further clue - I may or may not be helping. I have the XML extensions installed, which is why my "xml.sax.saxlib" is in "_xmlplus.sax" (in the "site-packages" folder). In Lib\xml\__init__.py is the following magic : try: import _xmlplus except ImportError: pass else: try: v = _xmlplus.version_info except AttributeError: # _xmlplue is too old; ignore it pass else: if v >= _MINIMUM_XMLPLUS_VERSION: import sys sys.modules[__name__] = _xmlplus else: del v This bit ``sys.modules[__name__] = _xmlplus`` tells python to use the XML extension as the XML module instead of the default one. However - there is also some nice(!) magic going on in "Lib\xml\sax\__init__.py" def _create_parser(parser_name): drv_module = __import__(parser_name,{},{},['create_parser']) return drv_module.create_parser() This is creating parsers and inserting them into the "xml.sax" namespace. I have disgnosed the problem... but not suggested a solution ! Hopefully someone else can see clearly... Best Regards, Fuzzy http://www.voidspace.org.uk/python (Anyone know a good host ?) > Regards, > > Fuzzyman > http://www.voidspace.org.uk/python > (when it works :-( > >> -- >> Steve Dicks >> Rawflow Ltd >> >> >> ------------------------------------------------------- >> SF.Net email is sponsored by: Discover Easy Linux Migration Strategies >> from IBM. Find simple to follow Roadmaps, straightforward articles, >> informative Webcasts and more! Get everything you need to get up to >> speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click >> _______________________________________________ >> Py2exe-users mailing list >> Py2...@li... >> https://lists.sourceforge.net/lists/listinfo/py2exe-users >> >> >> > > > > ------------------------------------------------------- > SF.Net email is sponsored by: Discover Easy Linux Migration Strategies > from IBM. Find simple to follow Roadmaps, straightforward articles, > informative Webcasts and more! Get everything you need to get up to > speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click > _______________________________________________ > Py2exe-users mailing list > Py2...@li... > https://lists.sourceforge.net/lists/listinfo/py2exe-users > > > |
From: Stephen D. <ste...@ra...> - 2005-06-22 15:53:29
|
>> >> > Stephen , > > Further clue - I may or may not be helping. I have the XML extensions > installed, which is why my "xml.sax.saxlib" is in "_xmlplus.sax" (in > the "site-packages" folder). I didnt have those extensions installed. Now I have, everything works fine. I think I brought the code directly from Unix which has the extension installed, which was the main crux of the problem :-( -- Steve Dicks Rawflow Ltd |
From: Thomas H. <th...@py...> - 2005-06-23 11:59:26
|
Michael Foord <mi...@pc...> writes: > Further clue - I may or may not be helping. I have the XML extensions > installed, which is why my "xml.sax.saxlib" is in "_xmlplus.sax" (in > the "site-packages" folder). > > In Lib\xml\__init__.py is the following magic : > > try: > import _xmlplus > except ImportError: > pass > else: > try: > v = _xmlplus.version_info > except AttributeError: > # _xmlplue is too old; ignore it > pass > else: > if v >= _MINIMUM_XMLPLUS_VERSION: > import sys > sys.modules[__name__] = _xmlplus > else: > del v > > This bit ``sys.modules[__name__] = _xmlplus`` tells python to use the > XML extension as the XML module instead of the default one. py2exe does handle this, with the modulefinder's ReplacePackage mechanism. From py2exe\build_exe.py: def create_modulefinder(self): from modulefinder import ModuleFinder, ReplacePackage ReplacePackage("_xmlplus", "xml") Thomas |