[IronPython] [python] *.pyd files usage in Iron python
Michael Foord
fuzzyman at voidspace.org.uk
Wed Dec 26 20:58:16 CET 2007
John Fletcher wrote:
> Thanks Michael for your reply.
>
> I tried the approach mentioned in
> http://www.voidspace.org.uk/ironpython/cpython_extensions.shtml
> <http://www.voidspace.org.uk/ironpython/cpython_extensions.shtml> and
> added a new function in the cext.py to call the win32 extensions:
I will take a look at this and report back.
In general though the win32 modules should be the *easiest* ones to port
to .NET as the win32 functionality is almost always exposed by .NET.
Michael
http://www.manning.com/foord
>
> *def createFilexx():
> print "Before Importing Win32File"
> import win32file
> print " Importing Win32File - Success"
> x =
> win32file.CreateFile("C:/john_text.txt",0,0,None,2,3,None)
>
> print " Creation of file - Success"
> *
> In the command prompt, I executed the following as follows:
>
> >>> import sys
> >>> sys.path.append("C:\Documents and
> Settings\john\Desktop\cext-ironpy-0.1.4
> \cext-ironpy-0.1.4")
> >>> sys.path.append("C:\Program Files\Python24\Lib")
> >>> sys.path.append("C:\Program Files\Python24\Lib\site-packages\win32")
> >>> import cext
> >>> cext.install()
> >>> cext.createFilexx()
> Loading the module win32file
> FileName C:\Program Files\Python24\Lib\site-packages\win32\win32file.pyd
> Traceback (most recent call last):
> File , line 0, in ##206
> File , line 0, in _stub_##145
> File C:\Documents and Settings\john\Desktop\cext-
> ironpy-0.1.4\cext-ironpy-0
> .1.4\cext.py, line 41, in createFilexx
> File , line 0, in _stub_##346
> File , line 0, in _stub_##347
> File , line 0, in _stub_##348
> File embedding, line unknown, in f
> File C:\Documents and Settings\john\Desktop\cext-
> ironpy-0.1.4\cext-ironpy-0
> .1.4\embedding.py, line 36, in f
> File , line 0, in _stub_##307
> File embedding, line unknown, in f
> File C:\Documents and
> Settings\john\Desktop\cext-ironpy-0.1.4\cext-ironpy-0
> .1.4\embedding.py, line 48, in f
> File , line 0, in _stub_##331
> File C:\Documents and
> Settings\john\Desktop\cext-ironpy-0.1.4\cext-ironpy-0
> .1.4\embedding.py, line 95, in PyExcConvert
> File , line 0, in _stub_##375
> File , line 0, in _stub_##376
> File C:\Program Files\Python24\Lib\ihooks.py, line 403, in import_module
> File , line 0, in _stub_##218
> File , line 0, in _stub_##219
> File C:\Program Files\Python24\Lib\ihooks.py, line 447, in
> find_head_package
> *ImportError: No module named pywintypes*
>
> In this context, I want to know, if this cextension module has any
> known caveats wrt Win types ?
>
> Cheers,
> John
>
> On Dec 26, 2007 6:45 PM, Michael Foord < fuzzyman at voidspace.org.uk
> <mailto:fuzzyman at voidspace.org.uk>> wrote:
>
> John Fletcher wrote:
> > All,
> >
> > I am trying to port the existing Python code to Iron python. To use
> > most of the existing python functionalities , I have a path to the
> > python installation(ie C:\python24\lib) in my *.py files. With
> this I
> > am able to import all the python libraries like "os", "clr"
> etc., But
> > if I try to import the libraries in *.pyd file, my execution
> complains
> > about its non-existence (eg: win32file, win32net, though they are
> > present in C:\python24\lib\site-packages\win32 ).
> >
> > Could any one let me know, how to deal with it ? or where can I get
> > the corresponding *.py files ?
>
> From the FAQ (
> http://www.codeplex.com/WorkItem/AttachmentDownload.ashx?ProjectName=IronPython&WorkItemId=2731&FileAttachmentId=869
> <http://www.codeplex.com/WorkItem/AttachmentDownload.ashx?ProjectName=IronPython&WorkItemId=2731&FileAttachmentId=869>
> - why is this a download?):
>
> Q: How do I build and call into PYD libraries?
>
> A: IronPython does not support using PYDs built for CPython since they
> leverage implementation details of CPython. You can get a similar
> effect for new "PYD"s you would like to implement by writing them
> in C#
> or VB and building a DLL for .NET.
>
> There is one approach - but really you are better off looking for
> native
> ways of doing what you need from IronPython:
>
> http://www.voidspace.org.uk/ironpython/cpython_extensions.shtml
>
> Michael
> http://www.manning.com/foord
>
>
> >
> > Cheers,
> > John
> >
> ------------------------------------------------------------------------
> >
> > _______________________________________________
> > Users mailing list
> > Users at lists.ironpython.com <mailto:Users at lists.ironpython.com>
> > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> <http://lists.ironpython.com/listinfo.cgi/users-ironpython.com>
> >
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com <mailto:Users at lists.ironpython.com>
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
More information about the Ironpython-users
mailing list