[python-win32] Overlay Icon Question and network drives
Andrea Gavana
andrea.gavana at gmail.com
Thu Apr 17 13:16:16 CEST 2008
Hi Tim,
On Thu, Apr 17, 2008 at 11:57 AM, Tim Golden wrote:
> Andrea Gavana wrote:
> > Just an update: I have managed to make it running both as a Python
> > script and as a standalone executable/dll. It's working fine and it's
> > not slowing down our network connections: everything seems as fast as
> > before. A big thank you to Roger and Tim for their kind help!
>
> Thanks for the update, Andrea. Glad we could help.
> Is it worth your posting the solution to the problems you were
> having with py2exe for anyone following this thread?
Yes, sorry I didn't think about it. The main problem I was having was
due to the way I compiled the COM server with py2exe: every time I
opened some file dialogs from my apps I got this traceback:
pythoncom error: PythonCOM Server - The 'win32com.server.policy'
module could not be loaded.
<type 'exceptions.ImportError'>: No module named server.policy
pythoncom error: CPyFactory::CreateInstance failed to create instance.
(80004005)
Then, I just took the Setup.py file from TortoiseHG, modified it for
my COM server and compiled it using the py2exe option bundle_files=1
(i.e., single executable without external dependencies). This works
very well now. For the curious, this is my Setup.py file for my COM
server:
# ----------------------------------
# BEGIN CODE
# ----------------------------------
# SetupCOMServer.py
from distutils.core import setup
import py2exe
import sys
import shutil
# Remove the build tree... ALWAYS do that!
shutil.rmtree("build", ignore_errors=True)
# List of modules to exclude from the executable
excludes = ["pywin", "pywin.debugger", "pywin.debugger.dbgcon",
"pywin.dialogs", "pywin.dialogs.list"]
# List of modules to include in the executable
includes = ["win32com.server"]
# ModuleFinder can't handle runtime changes to __path__, but win32com uses them
try:
# if this doesn't work, try import modulefinder
import py2exe.mf as modulefinder
import win32com
for p in win32com.__path__[1:]:
modulefinder.AddPackagePath("win32com", p)
for extra in ["win32com.shell", "win32com.server"]: #,"win32com.mapi"
__import__(extra)
m = sys.modules[extra]
for p in m.__path__[1:]:
modulefinder.AddPackagePath(extra, p)
except ImportError:
# no build path setup, no worries.
pass
# Set up py2exe with all the options
setup(
options = {"py2exe": {"compressed": 2,
"optimize": 2,
"bundle_files": 1,
"dist_dir": "COMDist",
"excludes": excludes,
"includes": includes}},
# The lib directory contains everything except the executables and
the python dll.
# Can include a subdirectory name.
zipfile = None,
com_server = ['KSVR_COMServer'],
)
# ----------------------------------
# END CODE
# ----------------------------------
I hope this will help someone in the future :-D
Thanks for your help!
Andrea.
"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/
More information about the python-win32
mailing list