[IronPython] [python] *.pyd files usage in Iron python

John Fletcher jfletcher007 at gmail.com
Wed Dec 26 20:50:57 CET 2007


Thanks Michael for your reply.

 I tried the approach mentioned in
http://www.voidspace.org.uk/ironpython/cpython_extensions.shtml and added a
new function in the cext.py to call the win32 extensions:

*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> 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
> - 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
> > 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20071226/a9100601/attachment.html>


More information about the Ironpython-users mailing list