A bit more on IronPython
[Update 04.02.2007: Added note about running under the debugger]
[Update 03.14.2007: Updated content for Visual Studio 2005 SDK Version 4.0]
[Update 01.23.2007: Added note about needing VC++]
[Update 09.15.2006: Updated content for Visual Studio 2005 SDK Version 3.0]
[Update 07.26.2006: Soma linked to my blog :). Because of this, I've made some minor edits to bring this post a bit more up to date.]
Since there have been several mentions of this blog on the IronPython discussion alias, I thought I should mention some more about the IronPython sample in the latest release of the Visual Studio SDK.
How do I get IronPython Integration in Visual Studio 2005?
First, you'll need to go download the latest release of the Visual Studio SDK (Version 4.0). Note that the IronPythonIntegration sample will only work with Visual Studio 2005 (and higher). It is not possible to get it to work with .Net 1.1 and Visual Studio 2003.
What version of Visual Studio do I need? Can I use this with an Express edition?
Unfortunately, no. The Visual Studio Express editions do not support extensibility (addins & packages). This is a limitation of the Express products and not a limitation we are placing on the sample. You will need Visual Studio Standard or higher to build and use the sample.
Also, you will need to have Visual C++ installed in order to compile the sample. This is a current prerequisite for building any Visual Studio integration project since the C++ preprocessor is used to compile the CTC files in the sample. (CTC is the format that is used to statically describe the menu structure that a package provides in Visual Studio.)
OK, I've got this thing downloaded...now how do I get IronPython working inside Visual Studio?!?
Open Visual Studio 2005 and (assuming you installed the SDK to the default location) open the solution at "C:\Program Files\Visual Studio 2005 SDK\2007.02\VisualStudioIntegration\Samples\IronPythonIntegration". Then, it should simply be a matter of hitting CTRL+F5 for Build & Run. This will launch Visual Studio using the "Experimental hive". (Alternatively, you could run "devenv /rootsuffix Exp" or use the shortcut that is placed under VS SDK in the Start Menu.)
Note that if you run the sample via F5 (under the debugger), you may see some exceptions and MDA (managed debugging assistant) errors. These can be safely ignored.
I think I have it built and running...now what?
You can create a new IronPython project just like you would a C#/VB/J#/C++ project, from the new project command. My suggestion would be to create a console application and play around with that for a while. If you open any file with a .py extension, you'll notice that Visual Studio will do syntax coloring for you.
One other cool little item this sample includes is a tool window (like Output Window, Solution Explorer, etc...) called the IronPython Console Window. You can launch this from View-Other Windows.
Another thing to note with the console window is a variable defined in it called "dte". This is a pointer to the same DTE object that is used to automate Visual Studio via the Macros IDE. Translation: you can write mini-macros for VS with IronPython instead of Visual Basic. :-)
How does this compiler thing work anyway? I haven't been able to 'compile' IronPython binaries before...
Over the past few months, the IronPython team added some compiler interfaces to IronPython.dll which the IP project system uses to compile when you select "Build". One thing to realize about how the compiler works is that the binaries produced have a heavy dependency on the IronPython runtime (IronPython.dll). After all, it is a dynamic language. When you execute your IronPython binary, each statement is being evaluated and type-checked as you execute it.
What this means for you is that the MSIL in the binaries produced will not look like a standard .NET library you build in C#/VB. In fact, you probably won't be able to consume it from another project.
What other features are there?
This sample is primarly meant as a sample to demonstrate integrating a language into Visual Studio 2005. As such, some of the features may be incomplete or unstable. Nevertheless, the sample has limited support for the following features:
- MSBuild
- Windows Forms Designer
- WebSite Projects (e.g. "New Website")
- Web Application Projects
- Intellisense (Both as inline in a aspx page and in normal code files)
- Demonstrates use of MPF features
I have multiple modules (.py files) that need to interact with each other. How does that work?
Simple. In your project, just import the module like you would if you had a bunch of .py files on disk together in the same folder. For example, if I have program.py as my main file and I need to import myModule.py, I would put the following statement in program.py:
import myModule
Which version of IronPython is included in this sample?
The Visual Studio 2005 SDK Version 4.0 uses a pre-beta version of IronPython 1.1.
Is there any way to get IronPython running in Visual Studio without downloading the Visual Studio 2005 SDK?
At the present, the only method we are using for shipping the IronPython/VS integration is as a sample in the VSSDK.
However, the IronPython team has released an IronPython for ASP.NET CTP which includes a subset of the functionality included in this sample. Note that the IronPython for ASP.NET CTP is shipped in binary form only, and it does not require the Visual Studio SDK.
OK, I think I found a bug...
Please send us feedback with any problems/questions/suggestions you may have!
Comments
- Anonymous
February 18, 2006
PingBack from http://www.spatiallyadjusted.com/2006/02/18/ironpython-and-esris-net-framework/ - Anonymous
May 28, 2006
Here are just a few that I found, both on Python and IronPython:
Python Library Reference
Python... - Anonymous
July 25, 2006
One of the great features of the .NET framework is the Common Language Infrastructure (CLI).  The... - Anonymous
July 26, 2006
Comme l'annonce Somasegar au travers de son blog, voici l'implémentation du langage Python pour le .NET... - Anonymous
July 26, 2006
IronPython开发组宣布了IronPython 1.0 RC1,估计几周之内会发布正式版。 - Anonymous
July 27, 2006
IronPython1.0ReleaseCandidateOneofthegreatfeaturesofthe.NETframeworkistheCommonLa... - Anonymous
July 29, 2006
IronPython1.0ReleaseCandidateOneofthegreatfeaturesofthe.NETframeworkistheCommonLa... - Anonymous
August 02, 2006
http://blogs.msdn.com/aaronmar/archive/2006/02/16/533273.aspx太强了 - Anonymous
September 06, 2006
For those of you interested in using Python, Microsoft has released the 1.0 version of this tool.
There... - Anonymous
September 09, 2006
PingBack from http://mdavey.wordpress.com/2006/09/09/catching-up/ - Anonymous
September 13, 2006
PingBack from http://www.andreas-schlapsi.com/2006/09/14/ironpython-languagebinding-fur-sharpdevelop/ - Anonymous
December 18, 2006
Python文档:http://blog.csdn.net/ccat/category/9998.aspxAbitmoreonIronPython:http://blogs.msdn.co... - Anonymous
December 18, 2006
Python文档: http://blog.csdn.net/ccat/category/9998.aspx A bit more on IronPython: http://blogs.msdn.com/aaronmar/archive/2006/02/16/a-bit-more-on-ironpython.aspx - Anonymous
May 27, 2007
Any idea what changes needed for ItronPython 2.0 ?Regarding the Website project type, does it conflict with ASP.NET May 2007 Futures CTP IronPython support ? - Anonymous
May 29, 2007
Hi Mohamed,The sample is not designed to work with IronPython 2.0 and we have no plans (at the present time) to upgrade it (as it is meant as an integration sample).I don't believe that the website types conflict, although hopefully you wouldn't hit this anyway as the IronPython sample registers in the VS Experimental Hive (meaning...it doesn't register with the primary VS registration and potentially mess up some other package).Thanks,Aaron - Anonymous
September 20, 2007
Aaron,I am interested in migrating some python code into a .Net class. If possible, i'd like to use Iron Python if the class would be consumable as a com class.Specifically, would be a class to read nk2 files.Generally speaking will IronPython be a good approach for this, or should I use c# instead?/bac - Anonymous
September 20, 2007
Here is a link to the code to be migrated: http://debunk2.googlecode.com/svn/trunk/nk2parser.py - Anonymous
September 20, 2007
Hi Bob,While there is an IronPython "compiler", the MSIL code that it produces is not easily consumable from other .NET or COM languages. If you are creating code that will be consumed via COM, I would recommend using C#.Thanks,Aaron - Anonymous
April 25, 2009
Hello, thnks for the info and the link... - Anonymous
April 25, 2009
I think peaking will IronPython be a good approach for this. - Anonymous
June 28, 2009
Hi..I installed visual studio shell edition 2008 but is'n it compatible w Iron Python 2??..how have I install this?..I install using .msi but the python project never appear inside vs shell...please help - Anonymous
July 06, 2009
@angel The IronPythonIntegration sample in the 2008 SDK only works with IronPython 1.1. There are no plans to update it to 2.0. IronPythonStudio on Codeplex also only supports IronPython 1.1.For IronPython 2.0+ IDE plans, I would suggest contacting Harry Pierson (http://www.devhawk.net/).-Aaron - Anonymous
March 25, 2010
How would I go about adding a reference to the IronPython instance in Visual Studio? The typical right click functionality to add a reference doesn't work, which isn't a surprise, so how would I go about modifying the IronPython solution to incorporate an additional library or is there an alternative to do this?