[IronPython] Pywin32 porting woes...
wsadkin at ParlanceCorp.com
Wed May 12 20:19:50 CEST 2010
I am not sure who to go to with this...
We have a large legacy CPython library set that makes extensive use of
the pywin32 extensions Mark Hammond wrote. I would like to use
IronPython to build a RESTful service around the use of this code, but
have discovered that this will be problematic at best, and impossible at
I saw through some net searching that William Reade managed to get some
portions of win32api to work last year using ironclad
So I thought I'd try to see how far I could get with some of the win32
stuff... I managed to get win32api to import with a zillion warnings,
but when I tried to import pythoncom, I got errors nesting down to a
problem with the import of pywintypes.
Looking into the code, it assumes that sys.platform startswith("win32")
must be True if it's windows; this isn't the case with ipy; instead it's
Ok, easy to modify, to get to the next issue in the onion, which I'm
'import pythoncom' fails. I've worked through the code enough to track
down the source of this to problems importing from the pywintypes dll.
It turns out that in cpython:
Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit
>>> import imp
<module 'pywintypes' from 'C:\Windows\system32\pywintypes26.dll'>
That is, imp.load_dynamic() returns a module object for this.
In ipy :
C:\> C:\Program Files (x86)\IronPython 2.6\ipy.exe
IronPython 2.6 (2.6.10920.0) on .NET 2.0.50727.4062
>>> import sys
>>> import ironclad
>>> import imp
That is, in ipy, the imp.load_dynamic() *doesn't* return a module, and
raises no exception or anything that would indicate why this was the
Which leads to the following questions:
1) Can anyone tell me why this is?
2) Is this an ironclad issue, an ipy bug, an incompatible change in
imp's behavior in ipy, or something else?
3) Is this a path worth pursuing?
4) If not, can anyone give me any recommendations for what to use
instead of ipy?
5) Also, as an aside, will ironpython ever support .pth files to augment
the module search path?
More information about the Ironpython-users