<div dir="ltr">This brings up an interesting question. How much of a pure .NET implementation do we want to keep in IronPython? Do we want to try and pull something like IronClad into IronPython to provide compatibility, or implement the important modules in .NET?</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 3, 2014 at 5:12 AM, Jeff Hardy <span dir="ltr"><<a href="mailto:jdhardy@gmail.com" target="_blank">jdhardy@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Baron,<br>
Sorry for the late reply. You've encountered the biggest issue with<br>
IronPython, which is that it can't load Python extensions that are<br>
written in C.<br>
<br>
In this case, the _AES modules (_AES.so) is a C library that depends<br>
on CPython's implementation. Unfortunately, if PyCrypto doesn't<br>
provide a pure-Python fallback (and it looks like it doesn't, although<br>
I may have missed it), there's no way to get it to work in IronPython<br>
(there is the old IronClad project, but it hasn't been updated in<br>
years and almost certainly would not work with current versions).<br>
<span class="HOEnZb"><font color="#888888"><br>
- Jeff<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On Wed, Oct 29, 2014 at 10:43 PM, Baron Oldenburg<br>
<<a href="mailto:Baron.Oldenburg@leviathansecurity.com">Baron.Oldenburg@leviathansecurity.com</a>> wrote:<br>
> Hello!<br>
><br>
><br>
><br>
> I’m attempting to import a module (KillerBee) in IronPython. I’ve<br>
> encountered a couple of issues along the way, some of which I’ve been able<br>
> to fix. I’m hoping the mailing list can help me out with what I haven’t<br>
> fixed. Here are the problems I’ve encountered and the steps I’ve taken:<br>
><br>
><br>
><br>
> 1. “Exception during object creation: no module named killerbee”<br>
><br>
> a. Per<br>
> <a href="http://stackoverflow.com/questions/1371994/importing-external-module-in-ironpython" target="_blank">http://stackoverflow.com/questions/1371994/importing-external-module-in-ironpython</a>,<br>
> I added the following which allowed IronPython to recognize killerbee as a<br>
> module and let me import it:<br>
><br>
> var paths = engine.GetSearchPaths();<br>
><br>
> paths.Add(@"/usr/lib/python2.7/site-packages/");<br>
><br>
> engine.SetSearchPaths(paths);<br>
><br>
> 2. “Exception during object creation: cannot import _AES from<br>
> Crypto.Cipher”<br>
><br>
> a. I tracked this error down to this line in a killerbee file<br>
> “dot154decode.py”:<br>
><br>
> “from Crypto.Cipher import AES”<br>
><br>
> and then further to /usr/lib/python2.7/site-packages/Crypto/Cipher/AES.py:<br>
><br>
><br>
> “from Crypto.Cipher import _AES”<br>
><br>
> In the same directory as AES.py there is an _AES.so.<br>
><br>
> b. If I attempt this from the python interpreter, there are no errors:<br>
><br>
> $ python<br>
><br>
> Python 2.7.8 (default, Sep 24 2014, 18:26:21)<br>
><br>
> [GCC 4.9.1 20140903 (prerelease)] on linux2<br>
><br>
> Type "help", "copyright", "credits" or "license" for more information.<br>
><br>
>>>> from Crypto.Cipher import AES<br>
>>>> import Crypto<br>
>>>> print Crypto.__version__<br>
><br>
> 2.6.1<br>
><br>
>>>><br>
><br>
> c. If I attempt this from IronPython with the following code (instead<br>
> of importing killerbee):<br>
><br>
> engine.ImportModule("Crypto.Cipher.AES");<br>
><br>
> I get the same error (“cannot import _AES from Crypto.Cipher”).<br>
><br>
> d. If I attempt to just import Crypto.Cipher<br>
> (“engine.ImportModule("Crypto.Cipher");”) there are no errors.<br>
><br>
> Before I start trying increasingly complicated workarounds, does anyone have<br>
> an idea as to the possible root cause? I’ve searched around on the Internet<br>
> generally and in outstanding IronPython issues specifically for other people<br>
> with this problem, but I’ve only found the following semi-related hits<br>
> around IronPython and pycrypto:<br>
><br>
><br>
><br>
> ·<br>
> <a href="http://stackoverflow.com/questions/2365661/how-to-create-a-package-in-c-sharp-for-use-in-ironpython" target="_blank">http://stackoverflow.com/questions/2365661/how-to-create-a-package-in-c-sharp-for-use-in-ironpython</a><br>
><br>
> · <a href="http://www.pyinstaller.org/ticket/881" target="_blank">http://www.pyinstaller.org/ticket/881</a><br>
><br>
> ·<br>
> <a href="http://lists.ironpython.com/pipermail/users-ironpython.com/2006-November/018956.html" target="_blank">http://lists.ironpython.com/pipermail/users-ironpython.com/2006-November/018956.html</a><br>
><br>
> · <a href="https://bitbucket.org/mvdk/ironpycrypto" target="_blank">https://bitbucket.org/mvdk/ironpycrypto</a><br>
><br>
><br>
><br>
> The relevant parts of the source look like this:<br>
><br>
><br>
><br>
> using IronPython;<br>
><br>
> using IronPython.Hosting;<br>
><br>
> using Microsoft.Scripting;<br>
><br>
> using Microsoft.Scripting.Hosting;<br>
><br>
><br>
><br>
> ScriptEngine engine = Python.CreateEngine();<br>
><br>
> var paths = engine.GetSearchPaths();<br>
><br>
> paths.Add(@"/usr/lib/python2.7/site-packages/");<br>
><br>
> engine.SetSearchPaths(paths);<br>
><br>
> engine.ImportModule("Crypto.Cipher.AES");<br>
><br>
><br>
><br>
> Thanks for your time! I’m happy to provide any other details or source code<br>
> necessary to continue debugging.<br>
><br>
><br>
><br>
> Baron<br>
><br>
><br>
</div></div><div class="HOEnZb"><div class="h5">> _______________________________________________<br>
> Ironpython-users mailing list<br>
> <a href="mailto:Ironpython-users@python.org">Ironpython-users@python.org</a><br>
> <a href="https://mail.python.org/mailman/listinfo/ironpython-users" target="_blank">https://mail.python.org/mailman/listinfo/ironpython-users</a><br>
><br>
_______________________________________________<br>
Ironpython-users mailing list<br>
<a href="mailto:Ironpython-users@python.org">Ironpython-users@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/ironpython-users" target="_blank">https://mail.python.org/mailman/listinfo/ironpython-users</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Website: <a href="http://earl-of-code.com" target="_blank">http://earl-of-code.com</a>
</div>