Skip to content

Commit 80a90e6

Browse files
committed
Python: Remove work-around for broken comtypes TypeLib unregistration
Replace with a comtypes version check to ensure that a sufficiently new comtypes version is present.
1 parent 6076088 commit 80a90e6

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

MyExeServerPy/MyExeServerPy.py

+4-9
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
# * Delete the "comtypes.client.gen_dir" folder when changing a COM interface without updating the GUID, or
66
# * Set "comtypes.client.gen_dir = None" during script startup to disable caching (doesn't always work).
77

8+
from packaging.version import parse
9+
if parse(comtypes.__version__) < parse("1.4.9"):
10+
raise ImportError("comtypes 1.4.9 or newer required due to https://github.com/enthought/comtypes/pull/678")
11+
812
# Load type library
913
MyInterfaces = comtypes.client.GetModule("../x64/Debug/MyInterfaces.tlb")
1014
#MyInterfaces = comtypes.client.GetModule("../x64/Release/MyInterfaces.tlb")
@@ -38,12 +42,3 @@ def Unsubscribe(self, client):
3842
if __name__=="__main__":
3943
from comtypes.server.register import UseCommandLine
4044
UseCommandLine(MyServerImpl) # will parse /regserver and /unregserver arguments
41-
42-
from packaging.version import parse
43-
if parse(comtypes.__version__) <= parse("1.4.8"):
44-
import sys
45-
if sys.argv[-1] == "/unregserver":
46-
# Work-around for broken comtypes TypeLib unregistration in 64bit (https://github.com/enthought/comtypes/pull/678)
47-
import comtypes.typeinfo
48-
tlb = MyInterfaces.MyServer._reg_typelib_ # (GUID, verMajor, verMinor) triple
49-
comtypes.typeinfo.UnRegisterTypeLib(tlb[0], tlb[1], tlb[2], 0, comtypes.typeinfo.SYS_WIN64) # override SYS_WIN32 default

0 commit comments

Comments
 (0)