Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm writing a C# GUI application where I'd like to use numpy, which I have used under Python 2.7 extensively and which is very fast and easy to program. (I still find the GUI work in C# much easier to use than PyQt.)

An IronPython port of numpy and scipy exists now and I'd like to learn how to use it.

Before starting, I'd like to know what kind of deployment options I will have? Can I fully wrap python and numpy or do I have to install python, Ironpython, numpy on my customer's machines?

share|improve this question
    
What versions of Iron Python are you using? What CLR? –  Preet Sangha Feb 14 '13 at 23:52
    
I'm still using my own math (mostly 4x4 matrices) for the portion that is numerical. Just using C# (.Net 4.0) for now. I'd be flexible for ease of deployment, since I'm not using any advanced C# features. –  roadrunner66 Feb 15 '13 at 0:54
1  
The dlr is already installed with .net 4. So you won't have to install that. You can usually just dump the IronPython assemblies and your custom assemblies in that case. I don't know about numpy - you'll have to check with them. –  Preet Sangha Feb 15 '13 at 0:57
1  
IronPython also needed the Python stdlib last time I checked. –  wRAR Feb 15 '13 at 1:38

1 Answer 1

up vote 1 down vote accepted

You can wrap Ironpython code to a .net assembly as a DLL or exe. If you need to load the code from other .NET code, create a DLL using an IronPython script

import clr
clr.CompileModules(dllname, module1.py, module2.py,...)

then load that assembly with

Assembly dpma = Assembly.LoadFile(Path.GetFullPath("CompiledIronPythonModule.dll"));
pyEngine.Runtime.LoadAssembly(dpma);

(C# example). In VisualStudio you will need references to IronPython and the dll in the project.

I just succeeded in compiling numpy and scipy-refactored from scratch with IronPython 2.7.5, Visual Studio 2012 .NET 4.0 with Intel Fortran Composer XE 2013 (using the latter needed some changes to the scipy iron_setup.py files). The output are a set of DLLs. I can at this point import the modules on the IronPython command line. What's not working yet is how to cook IronPython code with a numpy/scipy import into a .net assembly. For this, I will be checking into ironpycompiler.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.