Folks,
I have run into a problem that is py2exe & win32 related, but I am not
sure which
toolkit has the problem...
----
from win32com.client import gencache
gencache.EnsureModule('{565783C6-CB41-11D1-8B02-00600806D9B6}', 0, 1, 2)
----
Has anyone used py2exe, and started to get the following errors when you
use a typelib
with py2exe? (I am working through this on the py2exe mailing list, but
since it's
related to the win32 libraries, I thought I would ask here as well...)
I think I figured what is causing it... But I am not sure how to fix
it...
>running py2exe
>*** generate typelib stubs ***
>error:
>C:\develope\security\build\bdist.win32\winexe\temp\win32com\gen_py\5657
83
>C6-CB41-11D1-8B02-00600806D9B6x0x1x2\SWbemObject.py: No such file or
>directory
I believe from moving the build location around that somehow an IMP
import is
preventing py2exe from properly gathering the typelib stubs....
The following code is a general purpose build routine that I use....
(BAS_init is a general purpose start routine, that includes
configparser, logging, and other commonly used routines.... bas_common
is similar but contains general purpose code that I use in a lot of
programs... Those modules can be reverse engineered easily... Or let me
know if you want copies of the modules)
But what happens is that I use the IMP module to load the application so
that I can grab the author, name, description, and version data from the
application. This way I can use the same build routines for *every*
application.
If I move the build code to before the IMP load, it seems to work fine.
If I move it after the IMP load, it fails with the "No such file or
directory...." error...
Any suggestions?
- Benjamin
---------------------------------------------------------------------
from distutils.core import setup
import py2exe
import bas_init
import sys
import os
import imp
import bas_common
initialization_data = bas_init.initialization_wrapper ()
initialization_data.cmd_line_interface.add_option ("-b", "--build",
action="store", type="string", dest="app_to_build", help="Application to
Build", default="source.py")
initialization_data.cmd_line_interface.add_option ("-w", "--windows",
action="store_true", dest="Windows_Mode", help="Windows Mode",
default=False) initialization_data.run_cmd_line_parse ( )
application_name = initialization_data.cmd_line_options.app_to_build
application_name = os.path.splitext( application_name )[0]
windows_mode = initialization_data.cmd_line_options.Windows_Mode
try:
file, path, description = imp.find_module(application_name) except
ImportError:
print "Unable to find Build Target"
sys.exit(5)# deal however you wish with the module not being found
else:
try:
tool = imp.load_module("application", file,path,description)
finally: file.close()
#>>> # Use these commands in Python code to auto generate .py support
#from win32com.client import gencache
#gencache.EnsureModule('{565783C6-CB41-11D1-8B02-00600806D9B6}', 0, 1,
2)
if windows_mode:
print "Windows"
setup(windows=[initialization_data.cmd_line_options.app_to_build],
author = tool.__author__ ,
name = tool.__application_name__,
description = tool.__description__,
version = tool.__version__,
zipfile="system_files\\library.zip",
options = {"py2exe":{ "optimize":2,
"typelibs" :
[('{565783C6-CB41-11D1-8B02-00600806D9B6}', 0, 1, 2)],
"packages": ["encodings"],
"compressed": 1}}
)
else:
print "Console"
setup(console=[initialization_data.cmd_line_options.app_to_build],
author = tool.__author__ ,
name = tool.__application_name__,
description = tool.__description__,
version = tool.__version__,
zipfile="system_files\\library.zip",
options = { "py2exe":{"optimize":2,
"typelibs" :
[('{565783C6-CB41-11D1-8B02-00600806D9B6}', 0, 1, 2)],
"packages": ["encodings"],
"compressed": 1}}
)
_______________________________________________
Python-win32 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-win32