[lxml-dev] _elementpath.pyc and py2exe problem

Hi All, This is probably a question for py2exe developers but I'll ask it here too. I am trying to build a win32 .exe file with py2exe and it appears that py2exe cannot locate _elementpath.pyc correctly. The file does not get copied into the library.zip file. I can manually (or programatically with python's zipfile module) add _elementpath.pyc to the zip file and then the application works fine. Has anyone experienced this? Any ideas why? Thanks Greg -- Linux. Because rebooting is for adding hardware.

Hi, Greg Willden wrote:
This is probably a question for py2exe developers but I'll ask it here too.
I am trying to build a win32 .exe file with py2exe and it appears that py2exe cannot locate _elementpath.pyc correctly. The file does not get copied into the library.zip file. I can manually (or programatically with python's zipfile module) add _elementpath.pyc to the zip file and then the application works fine.
Has anyone experienced this? Any ideas why?
I'm not sure, but it may be because the only module that imports _elementpath.py is lxml.etree, which is a C module. So maybe py2exe just lacks the information that the module actually is a hard dependency of the package. But I wonder why only the _elementpath.pyc file should be affected, not the _elementpath.py file. Don't the .py files get included at all? Stefan

Hi Stefan, That is the conclusion I came to as well. The tool that searches for the modules is called modulefinder and is a part of the standard library. Modulefinder is unable to find _elementpath.* because it is only imported from the C code. My work-around was to add the following line to my code import _elementpath as DONTUSE #this is a workaround for Modulefinder and lxml You may wish to do something similar in lxml. It's not a matter of the .py versus .pyc because the executable (.exe) looks for pre-compiled files when it is run. Cheers, Greg On 8/31/07, Stefan Behnel <stefan_ml@behnel.de> wrote:
Hi,
Greg Willden wrote:
This is probably a question for py2exe developers but I'll ask it here too.
I am trying to build a win32 .exe file with py2exe and it appears that py2exe cannot locate _elementpath.pyc correctly. The file does not get copied into the library.zip file. I can manually (or programatically with python's zipfile module) add _elementpath.pyc to the zip file and then the application works fine.
Has anyone experienced this? Any ideas why?
I'm not sure, but it may be because the only module that imports _elementpath.py is lxml.etree, which is a C module. So maybe py2exe just lacks the information that the module actually is a hard dependency of the package.
But I wonder why only the _elementpath.pyc file should be affected, not the _elementpath.py file. Don't the .py files get included at all?
Stefan
-- Linux. Because rebooting is for adding hardware.

Hi Stefan, That is the conclusion I came to as well. The tool that searches for the modules is called modulefinder and is a part of the standard library. Modulefinder is unable to find _elementpath.* because it is only imported from the C code.
My work-around was to add the following line to my code import _elementpath as DONTUSE #this is a workaround for Modulefinder and lxml Why not change the setup.py and force py2exe to include all of lxml (with the "packages" option) or maybe the "includes" option for just
Greg Willden wrote: that file. Werner
participants (3)
-
Greg Willden
-
Stefan Behnel
-
Werner F. Bruhin