Planet IronPython

October 09, 2008

Dave Fugate (Testing IronPython)

Python Debuggers

I'm just curious to see how many Python developers out there actually use pdb.py, IDEs, etc to debug their code.  My personal preference is to simply pass "-i" to the interpreter.

October 09, 2008 10:34 PM

October 06, 2008

Miguel de Icaza

Mono 2.0 is out!

Today we released Mono 2.0 to the world. You can download sources and binaries from our download page. And our official release notes are up as well. This of course would not be possible without the open source contributors that worked tirelessly on Mono sending patches, fixing bugs, helping the community, answering questions, creating test cases and supporting us all these years.

Mono 2.0 is both a runtime for application and a kit for developers for writing applications with C# and other ECMA CLI languages for a wide spectrum of uses.

Big thanks go to the fantastic Mono team at Novell that has kept the excitement and the pace over all these years (we started in 2001), the large contributions from Mainsoft, Unity3D and our users that pushed us to fix bugs, implement new features and tune Mono. Also, we very much appreciate the work of the ECMA 334 and 335 committee members that worked on the CLI and C# specifications and everyone at Microsoft that answered our questions over the years and specially those that licensed code under open source licenses.

We originally started to work on Mono, because we wanted to make developers happier and more productive on Linux. We liked C#, we liked the CIL and we wanted to have those technologies available on our platform.

Since we have been active in the Linux Desktop world, it is not a surprise that the early use of Mono was mostly on Linux desktop applications, and Mono continues to shine there. Server-side use of Mono was a natural evolution and we soon were powering ASP.NET sites on Linux.

There is one area where we under-delivered in the past, and it has been a constant source of pain. Up until now, we did not have a working debugger. This has finally changed, and Mono 2.0 includes for the first time a debugger, the time for WriteLine() debugging is now behind us.

As the project matured, developers started taking advantage of Mono's open source nature: essentially .NET on their own terms. A platform that could be adapted, morphed, ported and modified to suit many different uses. Today Mono is embedded in portable mp3 players and powers Unity3D's game engine on the Apple iPhone, the Nintendo Wii, MacOS X and Windows (Some folks at Novell are working with Unity on bringing Unity3d to Linux!).

It has also been deployed to run code on large clusters of servers for SecondLife, powers our open source Silverlight implementation (Moonlight) and powers the popular DekiWiki: a Social Collaboration Tool.

Mono is a large project and it is hard to pick one feature to talk about as there are so many, so instead I put together a quick table of the major features that are part of this release:

Compiler Support .NET APIs Mono APIs
Mono's Open Source Compilers: Open Source Compilers: Commercial Compilers:
  • ISE's Eiffel.
  • Microsoft's C#.
  • Microsoft's F#.
  • Microsoft's VB.NET.
  • RemObject's Oxygene (Object Pascal).
And many more.
Core API:
  • 2.0 core APIs.
  • System, System.Xml.
  • 3.5 System.Core.
  • System.Drawing.
  • System.DirectoryServices.
  • System.Web.Services.
Windows.Forms 2.0:
  • Win32 driver.
  • Quartz/OSX driver.
  • Cairo/X11 Unix driver.
ASP.NET 2.0:
  • Core ASP.NET.
  • ASP.NET AJAX.
  • Apache and FastCGI integration.
ADO.NET 2.0 plus providers for:
  • Managed drivers: Postgresql, MS SQL Server, Sybase.
  • Semi-managed drivers: Firebird, IBM DB2, Oracle, Sqlite.
  • MySQL provides their own drivers.
GUI APIs:
  • Gtk# (Unix, Windows, MacOS X).
  • Cocoa# (MacOS X).
Mono Core:
  • Mono.Addins - Extensibility Framework.
  • Mono.Cairo - Cairo Graphics Binding.
  • Mono.Cecil - ECMA CIL Manipulation.
  • Xml.Relaxng.
  • Novell.Directory.Ldap
  • C5 - Generics Library.
Linux Specific: Other Ecosystem Libraries:
  • Bit# - Bittorrent client/server library.
  • Mono.Fuse - User-space file systems.
  • Mono.ZeroConf - Bonjour stack.
  • Mono.Nat - Network Address Translation.
  • Mono.Upnp - Universal Plug and Play.
  • Tao Framework - OpenGL, OpenAL, SDL and Cg bindings.

We have ported Mono to a wide variety of platforms and operating systems on this 1.0 to 2.0 cycle. These platforms include:

  • Linux (x86, x86-64, PowerPC32, Itanium, SPARC, ARM, s390, s390x.
  • Solaris (x86-64, SPARC).
  • MacOS X (x86, PowerPC32).
  • Windows (x86, support for x86-64 will come in Mono 2.2).
  • Nintendo's Wii.
  • iPhone/iPod Touch (ARM, limited functionality due to licensing requirements; I will blog later this week about this).
  • *BSD (x86, x86-64).

Developing with Mono

Long time Linux developers will probably continue to use Emacs and VI, but some new Linux developers might want to use an IDE. New developers can use our open source MonoDevelop IDE on Linux, or alternatively the commercial X-Develop IDE or SlickEdit.

If you are a Windows developer, you can continue using Visual Studio or your IDE of choice to write the code and compile it. Your binaries will run just fine on Linux.

To assist Windows developers in porting their applications to Unix, we have provided the Mono Migration Analysis tool.

Runtime Changes

The Mono Virtual Machine gained plenty of features since Mono 1.2 was released. We have added:

  • Generic Code Sharing and VTable Compression have been implemented: this significantly reduces the memory footprint of generic type instantiations, while still getting the speed benefits of using generics.
  • AOT support: in addition to x86, we now also support ARM and x86-64.
  • COM interop is now complete (works on Windows with "real COM" and can be used on Unix with Mainsoft's COM or Mozilla's XPCOM).
  • AOT code can now AOT parts of 2.0 assemblies (assemblies that contain generics).
  • Full AOT support (allows code to run JIT-less, this is limited to 1.0 code).
  • CIL Verifier: Now Mono has a CIL verifier.
  • CoreCLR Security: the security system used by Moonlight.
  • Many optimizations that improve execution performance: New intrinsics operations (Math.Min/Max for example); various operations are now inlined by the JIT; managed allocations (no transition to unmanaged code for allocating memory); multi-array access is now tuned by the JIT; constant and block initializations are now handled by the JIT; Faster initialization and access to multi-dimensional arrays (4x faster).
  • The runtime went on a diet, many runtime data structures are smaller making Mono lighter.

Tools

In addition the the Mono Debugger making its debut appearance on this release, we are very proud of our code analyzer Gendarme.

Gendarme is a extensible rule-based tool to find problems in .NET applications and libraries. Gendarme inspects programs and libraries that contain code in ECMA CIL format (Mono and .NET) and looks for common problems with the code, problems that compilers do not typically check or have not historically checked.

Feedback

Mono is not perfect, but we want to improve it. Like many other open source projects, we need your bug reports to improve Mono. If you have problems with Mono, help us by filing a bug report.

Special Thanks

Special thanks to Hacker Extraordinaire Aaron Bockover who not only brings us the best media player in the world, but created the new web site design and implemented and tuned it over very long extra hours up until 7am in the morning on his weekend.

And to our packaging and QA team that spent extra hours to get all the bits and pieces in place for the release.

by Miguel de Icaza (miguel@gnome.org) at October 06, 2008 10:46 PM

IronPython URLs

Compiling the DLR for Silverlight and IronPython with Silverlight RC0

Silverlight Release Candidate 0 is out, this means that the old versions of IronPython and the Dynamic Language Runtime don't work with the new version.

Silverlight includes a cut down version of the .NET framework called the Core-CLR. IronPython and DLR have to be compiled against the Core-CLR assemblies for the version of Silverlight you are targeting.

But IronPython is Open Source, so you can just compile it against the new Silverlight assemblies right? Jimmy Schementi explains:
"Of course! Everything should just work, since there were no major breaking changes in Silverlight that affect the DLR between Beta2 and RC0. So, you hacked up the csproj files to point at mscorlib.dll, system.dll, etc in the new Silverlight install directory (C:\Program Files\Microsoft Silverlight\2.0.30923.0), compile, and it builds fine. Then you try to run an app ..."

Next you need to make a simple change to your dynamic application to tell it about the new version of the runtime. Jimmy covers this in his blog entry as well. Of course rather than compiling IronPython yourself, it is easier to wait for Jimmy to release a new version of the SDK.
Jimmy also explains the changes in the DLR hosting API if you are hosting IronPython or IronRuby in your Silverlight application.

by Fuzzyman (noreply@blogger.com) at October 06, 2008 09:06 PM

October 05, 2008

The Voidspace Techie Blog

Total Ordering: Class Decorator for Filling in Rich Comparison Methods When Only One is Implemented

Raymond Hettinger managed to provide several of the highlights at PyCon UK. During a couple of his talks he extolled the virtues of class decorators which are new to Python 2.6 & 3.0. ... [621 words]

October 05, 2008 08:48 PM

The Voidspace Techie Blog

Dynamic Languages MVP, Blog Template, Conferences, Concurrency and Other Stuff

Last week I received an email from Microsoft: Congratulations! We are pleased to present you with the 2009 Microsoft MVP Award! ... [1131 words]

October 05, 2008 03:25 PM

October 04, 2008

Miguel de Icaza

Five Second Linux Boot

I loved this LWN article on the changes necessary to make Linux boot in 5 seconds on the Asus EEE PC (a relatively slow computer).

Hopefully all Linux distributions will adopt these changes for custom deployments.

by Miguel de Icaza (miguel@gnome.org) at October 04, 2008 04:54 PM

October 03, 2008

Miguel de Icaza

Moonlight Update: Media Codecs

A couple of weeks ago we started the work on porting Microsoft's Media Codecs to Linux and we got the C version running.

Popfly in Firefox3/Linux/x86

Geoff, Fernando and Rolf have been hard at work on this, and have also added the infrastructure to download and install the codecs on demand.

The next step was getting all the assembly language supported in Linux, and today Geoff got the assembly optimized SSE1 audio decoder running (the first chunk of the decoders).

Of course, the rest of the team has been busy fixing bugs and improving the performance in preparation for the first public beta of Moonlight.

by Miguel de Icaza (miguel@gnome.org) at October 03, 2008 11:31 PM

IronPython Cookbook (New Entries)

Settings File

MichaelFoord:


This example shows how to use Xml to create a simple settings file for configuration of an application. The __main__ section shows how to use the class and runs through the features.

One interesting part is the use of dict.fromkeys to remove duplicates from the Category list. If using this code in your own application, please note the (current) lack of error handling!

<pre>
import clr
clr.AddReference('System.Xml')
from System.Xml import XmlDocument
from System.IO import File

BasicXml = "<?xml version=\"1.0\"?><Settings></Settings>";

class AppSettings(object):
def __init__(self):
self._FilePath = ""
self._SetUp(BasicXml)
def _SetUp(self, Xml):
self.Document = XmlDocument()
self.Document.LoadXml(Xml)
def Get(self, Name):
Value = self.Document.SelectSingleNode("/Settings/" + Name).InnerText
return Value
def Set(self, Name, Value, Category=""):
OldNode = self.Document.SelectSingleNode("/Settings/" + Name)
if OldNode!=None:
self.Document.SelectSingleNode("/Settings").RemoveChild(OldNode)
ValNode = self.Document.CreateElement(Name)
if Category!="":
CategoryAttrib = self.Document.CreateAttribute("Category")
CategoryAttrib.Value = Category
ValNode.Attributes.Append(CategoryAttrib)
ValNode.InnerText = Value
self.Document.DocumentElement.AppendChild(ValNode)
def Load(self, FilePath):
self._FilePath = FilePath
rawXML = File.ReadAllText(self._FilePath)
self._SetUp(rawXML)
def Save(self, FilePath):
self._FilePath = FilePath
rawXML = File.WriteAllText(self._FilePath, self.Document.OuterXml)
def Output(self):
print self.Document.OuterXml
def AsList(self):
ns = self.Document.SelectNodes("/Settings")
SettingList = []
for n in ns:
for on in n.ChildNodes:
Item = {}
Item['Name'] = on.Name
Item['Value'] = on.InnerText
Item['Category'] = on.GetAttribute("Category")
SettingList.append(Item)
return SettingList
def Categories(self):
ns = self.Document.SelectNodes("/Settings")
CatList = []

for n in ns:
for on in n.ChildNodes:
cat = on.GetAttribute("Category")
if len(cat)>0:
CatList.append(cat)
return dict.fromkeys(CatList).keys()

if __name__ == "__main__":

print "Create settings object."
MySettings = AppSettings()

print "Set a few values."
MySettings.Set("Dog", "Dandy")
MySettings.Set("Cat", "Cola")
print "XML:"
MySettings.Output()

print "Get Settings"
print "[" + MySettings.Get("Dog") + "]"
print "[" + MySettings.Get("Cat") + "]"
print "XML:"
MySettings.Output()

print "Save to file."
MySettings.Save("test.xml")

print "Load Settings into another object."
MoreSettings = AppSettings()
MoreSettings.Load("test.xml")

print "Fetch value :" + MoreSettings.Get("Dog")
print "Fetch value :" + MoreSettings.Get("Cat")

print "Update Value:"
MoreSettings.Set("Cat", "Moggy")
print "XML:"
MoreSettings.Output()

print "Update Value:"
MoreSettings.Set("Dog", "Cola", "Springer")
print "XML:"
MoreSettings.Output()

print "Add Value:"
MoreSettings.Set("Hamster", "Giles", "Rodent")
print "XML:"
MoreSettings.Output()

print "--Walk through a list of the settings."
for item in MoreSettings.AsList():
print item['Name'] + "\t" + item['Value'] + "\t" + item['Category']

print "--Print All Categories."
for category in MoreSettings.Categories():
print category
print "--"
print "Save to file."
MySettings.Save("test.xml")
</pre>



Back to [[Contents]].

by Daftspaniel2 at October 03, 2008 09:08 PM

IronPython URLs

OpenBabel from IronPython

Noel O'Blog reports on the recent OpenBabel release that explicitly supports IronPython.
OpenBabel is:

"a chemical toolbox designed to speak the many languages of chemical data. It's an open, collaborative project allowing anyone to search, convert, analyze, or store data from molecular modeling, chemistry, solid-state materials, biochemistry, or related areas."

The OBDotNet release comes with instructions on how to use it from IronPython:

First of all, unzip the OBDotNet distribution, and set the environment variable BABEL_DATADIR to point to the data folder contained within.

If running IronPython in the unzipped OBDotNet folder, you can use the following to initialise OBDotNet:

>>> import clr
>>> clr.AddReference("OBDotNet")

Otherwise, you need to need to:
(1) add the OBDotNet distribution folder to the PATH environment variable
(2) include the full path to the OBDotNet.dll when adding the reference, as follows (note the 'r' at the start):

>>> import clr
>>> path = r"C:\Tools\OpenBabel\ob-22x\windows-vc2005\OBCSharp\OBDotNet-0.1\OBDotNet.dll"
>>> clr.AddReferenceToFileAndPath(path)

Once the reference to OBDotNet has been added, you can import and use the OpenBabel bindings just like from CPython:

>>> import OpenBabel as ob
>>> conv = ob.OBConversion()
>>> conv.SetInFormat("smi")
True
>>> mol = ob.OBMol()
>>> conv.ReadString(mol, "CCC")
True
>>> mol.GetMolWt()
44.09562

by Fuzzyman (noreply@blogger.com) at October 03, 2008 12:48 PM

October 02, 2008

Miguel de Icaza

Microsoft changes the Managed Extensibility Framework License

A couple of weeks ago I suggested that developers interested in having their .NET software run in other platforms should avoid Microsoft's Managed Extensibility Framework (MEF) as it was not an open source library.

I had a chance to discuss with Glenn, Sam and Bob the benefits of using the MS-PL for this library first over twitter and then over email.

Representing .NET's loyal competitor, I did not think that we stood a chance of getting Microsoft to change the license, but I was pleasantly surprised. Glenn understood the value of open source, Sam wanted to do the right thing about this library and CodePlex and Bob argued that Mono already had Mono.Addins anyways.

Today Glenn announced that Microsoft has changed the license for MEF to the open source MS-PL license.

Thanks to everyone at Microsoft that helped change the license!

by Miguel de Icaza (miguel@gnome.org) at October 02, 2008 08:56 PM

Miguel de Icaza

DbLINQ, LINQ to Databases and Mono

Atsushi Enomoto blogs about the work involved in bringing LINQ to Databases to Mono.

The effort was a joint collaboration between the awesome DbLINQ developers, Pablo Iñigo Blasco our Google Summer of Code Student and Novell's Atsushi Enomoto.

The DbLINQ developers had created a general purpose LINQ provider that could be used with database providers other than SQL Server. They also relicensed their code a few months ago to the MIT X11 license to allow for integration with Mono's code base.

Read Atsushi's description of how the effort was put together and how DbLINQ is being refactored to become a full System.Data.Linq implementation and still provide the foundation for third-parties to easily create database LINQ providers.

DbLINQ is a great project, and it needs your help to complete the effort.

by Miguel de Icaza (miguel@gnome.org) at October 02, 2008 12:28 AM

October 01, 2008

Miguel de Icaza

Mono at the PDC 2008

Great News Mono Lovers!

Later this month I will be presenting the session "Mono and .NET" at the Microsoft Professional Developers Conference in LA.

Exciting times!

Update: My talk will cover new technologies that we have created as part of Mono. Some of them are reusable on .NET (we try to make our code cross platform) and some other are features that specific to Mono's implementation of the CLI.

by Miguel de Icaza (miguel@gnome.org) at October 01, 2008 10:51 PM

Miguel de Icaza

Microsoft to incorporate jQuery into Visual Studio

This weekend the news came out that Microsoft was going to bundle and support John Resig's jQuery as part of Visual Studio and ASP.NET. From Scott's blog:

I'm excited today to announce that Microsoft will be shipping jQuery with Visual Studio going forward. We will distribute the jQuery JavaScript library as-is, and will not be forking or changing the source from the main jQuery branch. The files will continue to use and ship under the existing jQuery MIT license.

Beyond the obvious benefits to developers, what interests me is that Microsoft is now bundling an open source component into their commercial offerings.

This is a first time for Microsoft.

With IronPython they continued development of an open source project in house. With IronRuby, they were open to external contributions to the libraries of IronRuby. In both cases they were not taking external code or contributions directly into their core products.

Hopefully they will start using more open source code in their products. Maybe one day they will bundle Mono's Cecil or Mono's embeddable C# compiler.

by Miguel de Icaza (miguel@gnome.org) at October 01, 2008 07:49 PM

Jimmy Schementi

Dynamic Languages in Silverlight 2 RC0

I've just released the Silverlight Dynamic Languages SDK with the newest DLR, IronRuby, IronPython, and JScript binaries and sources to work against Silverlight 2 RC0!

 

Download the SDK!

 

This release works with Silverlight 2 RC0. Keep in mind this is a developer release, so no "end-user" runtime exists. This is why the "not-installed" experience doesn't take you directly to the download, but to a page where you can install the tools.

As usual, report any issues on the Issue Tracker, and feel free to ask any questions on the Discussions tab.

This release has slightly refactored Microsoft.Scripting.Silverlight, adding two new types: "Package" and "Configuration". You can use "Package" to access files inside the XAP, and "Configuration" can be used to detect languages available in Silverlight.

Hosting

In past releases, if you wanted to host the DLR you needed to create your own ScriptRuntimeSetup which uses Microsoft.Scripting.Silverlight.BrowserScriptHost to tell your hosted scripts about how Silverlight. Your code would look like this:

using Microsoft.Scripting.Silverlight;
using Microsoft.Scripting.Hosting;

//...

var setup = new ScriptRuntimeSetup();
setup.HostType = typeof(BrowserScriptHost);
var runtime = new ScriptRuntime(setup);

//...

Now, since the ScriptRuntimeSetup we use to run user code is public, you can simply this code to:

using Microsoft.Scripting.Silverlight;
using Microsoft.Scripting.Hosting;

//...

var runtime = DynamicApplication.Current.Runtime;

// or if you wanted to create your own runtime, reuse the setup

var runtime = new ScriptRuntime(DynamicApplication.Current.Runtime.Setup);

//...

Future

Blah, blah, blah, I always talk about the future. Has anything happened? Nope. Well, it will eventually. Just keep pestering. If you have no idea what I'm talking about, take a look at my last post.

by Jimmy Schementi (noreply@blogger.com) at October 01, 2008 07:10 AM

Jimmy Schementi

Compiling the DLR, IronRuby, and IronPython for ANY version of Silverlight

swan2008 (1)

I know you feel like this sometimes when trying to solve a problem. I do. Almost all the time. Even when I'm not angry ... but I digress.

Silverlight 2 RC0 was released this past Thursday, but anyone wanting to use the DLR in it was surprised ... no new binary release of the DLR bits for Silverlight 2 RC0 yet. As I said on Twitter, it would be delayed until today, but that shouldn't stop anyone from taking the sources and compiling them against the new SIlverlight build, right?

Of course! Everything should just work, since there were no major breaking changes in Silverlight that affect the DLR between Beta2 and RC0. So, you hacked up the csproj files to point at mscorlib.dll, system.dll, etc in the new Silverlight install directory (C:\Program Files\Microsoft Silverlight\2.0.30923.0), compile, and it builds fine. Then you try to run an app ...

"InitializeError- Failed to load the application. It was built with an obsolete version of Silverlight"

Poof! What the hell happened? That's a really bad error message, but what it means to say is:

"The application's AppManifest.xaml has a RuntimeVersion <= 2.0.30523.00, which is Silverlight 2 Beta 2's version number, so Silverlight 2 RC0 won't load this application."

So you see, the XAP file that was produced by Chiron is still for SL2 Beta2. But that's an easy fix;

  1. Make sure Chiron.exe isn't running.
  2. Go to your custom build, and edit Chiron.exe.config
  3. Find the <AppManifest.xaml> section, and where it says "RuntimeVersion" make it's value be "2.0.30923.0" (anything with the first three version numbers being greater than the current will do, but be save and use the actual version.)
  4. Re-run Chiron.exe, navigate to your Silverlight application, and .... it works!

Welcome to the wonderful world of versioning in Silverlight. :)

by Jimmy Schementi (noreply@blogger.com) at October 01, 2008 06:25 AM

September 30, 2008

IronPython URLs

Unit Testing in Python

The "Test Driven Developer", a .NET developer, has been using IronPython - and is "having a good time testing code with its built-in unit test framework".

He posts some example code with tests using the unittest module:
"This example should illustrate that we can write some unit tests for our Python code fairly easily and quickly. It's nice to have a built-in framework for unit testing. There is also a "doctest" module available for doing more like system testing."

by Fuzzyman (noreply@blogger.com) at September 30, 2008 08:00 PM

IronPython URLs

IronPython Talks to Google AppEngine

Joseph Jude has continued his experimenting with his time tracking tool and getting a desktop application (written in IronPython of course) - a time tracking tool - to use google authentication via the AppEngine.
He has made a new release of the client side tool, with configuration details to talk to his appspot application (the desktop tool can be used standalone without communicating with the server):

"I had the idea of having a server which will act as a centralized data repository - laptop/desktop tool, mobile tool should send data to the server and data will be analyzed in the server."

"Next steps? Incorporate with Google Charts to provide some neat analytics reports, so that it really becomes an useful tool."

by Fuzzyman (noreply@blogger.com) at September 30, 2008 07:55 PM

Hex Dump

OSDC 2008 Earlybird Registration is now open!

Earlybird Registration for The Open Source Developers' Conference 2008 is now open. OSDC 2008 is a conference run by open source developers, for developers and business people. It covers numerous programming languages across a rangeof operating systems, and related topics such as business processes, licensing, and strategy. Talks vary from introductory pieces through to the deeply technical.

by Mark Rees (noreply@blogger.com) at September 30, 2008 11:46 AM

September 29, 2008

The Voidspace Techie Blog

Resolver One in Italian and Resolver One 1.3

Resolver One is the incredible new desktop spreadsheet application I've been working on at Resolver Systems for the last two and a half years. It is written in IronPython and is 'highly programmable' (with Python of course). ... [572 words]

September 29, 2008 05:17 PM

Miguel de Icaza

Monovation: Assembly Injection into Live Processes

People are loving the C# Interactive Shell.

In the past people have embedded languages like Boo into their applications (MonoDevelop and Banshee for example both have options to embed Boo and a shell).

Zoltan designed a new system for Mono that allows developers to inject and execute code into running Mono applications. Paolo provided significant feedback and design guidelines for the code to be incorporated into Mono.

Thanks to both Zoltan and Paolo this functionality is now available through the Mono.Management assembly: you provide an executable and a PID, and the executable is injected and its Main method executed on the target process:

	using Mono.Attach;

	[..]

	// Get a handle to a running Mono process.
	VirtualMachine vm = new VirtualMachine (pid);

	// Load hello.exe into the target process, and run it
	vm.Attach ("/tmp/hello.exe", "");
	

You can use this for billions of things of course. You could patch running programs, you could attach logging software to a running program, or you could inject a C# evaluator into a live application and examine its state, or tweak it live.

Zoltan came up with a really cool extension to the the csharp command (this is the command-line C# Interactive Shell). The csharp command now takes an --attach command line argument and a PID.

The csharp shell can now use the Mono.Attach.VirtualMachine to injects itself into the remote process and then the client and server communicate through a couple of sockets.

For example, this is the sample that Zoltan used to pitch his idea for supporting attaching to the virtual machine. With the following you can pause a live Banshee process:

$ ps aux | grep banshee
miguel   12359 17.0  2.7 141372 55708 pts/5    Sl+  14:30   0:02 banshee-1 /usr/lib64/banshee-1/Nereid.exe
$ csharp --attach 12359
csharp> using Banshee.ServiceStack;
csharp> using Banshee.Gui;
csharp> var s = ServiceManager.Get ();
csharp> s.PlaybackActions ["PlayPauseAction"].Activate ();
	

All of the code is now on SVN, you need both the mono and mcs modules from trunk.

A GUI Shell

The above commands are a tiny bit risky and are also limited to the shell.

The above commands will execute on a separate thread from the application, and any commands that you execute would be executed on a separate thread which could corrupt the state of your application.

So this weekend, I wrote a tool that integrates with Gtk# applications, its called gsharp and you can find it in the mono-tools module (it borrows some code from Banshee).

gsharp is a Gtk# version of the csharp command. What is important is that it also supports injection of the code on other programs, but makes sure that all the code executes in the Gtk# thread, by issuing all of its commands from the Gtk# idle handler. This means that it is safe to use gsharp with your Gtk# applications.

GUI version of the tool.

Here you can select which project you want to inject the GUI into:

Needs some work, show process names.

This version shows the gsharp tool attached to F-Spot, as I am not very familiar with the codebase, I can not do very much with it:

We will need to implement one of these as well for Windows.Forms applications. This should luckily be easy to do as most of the smarts live in the Mono.CSharp assembly (our embeddable compiler).

Security of Agents

A couple of weeks ago, I asked for people to weigh in on a security concern for temporary files. This was for Zoltan's attach functionality.

The code is now implemented and I would love if security experts could do a source code audit of our implementation. And validate whether our assumptions are safe.

Here is the source code.

by Miguel de Icaza (miguel@gnome.org) at September 29, 2008 03:44 PM

September 28, 2008

Miguel de Icaza

Public Service Announcement

In C# the defaut access level for members in classes and structs is "private".

There is no need to pepper the source code with "private" everywhere. It only introduces noise and makes your code more difficult to read.

by Miguel de Icaza (miguel@gnome.org) at September 28, 2008 08:30 PM

September 26, 2008

IronPython URLs

Spider Python: Some Notes on IronPython

Some person on the internet has been learning IronPython. In order to learn IronPython he has ported a simple web spider (from a language called Retlang) and posted the Python code:
He is normally a C# developer (but he has tried Boo). He has also posted some notes on his first impressions of Python:
  • Python list comprehensions can do the same as LINQ for simple cases, but LINQ is much more powerful, and it supports deferred execution, while list comprehensions are evaluated greedily. (Ed: generator expressions are evaluated lazily in Python)
  • Every description of the python syntax I ever see emphasizes the fact you don't need to put in braces. Pity they don't spend more time telling you that you have to put in colons, that would actually be useful knowledge. This really bit me when I learnt boo, which is syntactically very similar.
  • IronPython 1.0 targets CPython 2.4. This sounds fine until you realize that this was released in 2004. A fair bit has happened since then, not limited to the introduction of an inline if syntax. (Ed: IronPython 2 is Python 2.5 which is still the stable current version of Python)
  • While we're on the subject, the inline if (defaultValue if condition else exceptionValue) is actually quite cool.
  • The fairly lax approach to types means I don't need to call .Cast anymore.
  • Tabs are the devil as far as indents in Boo and Python are concerned. I highly recommend using something that shows tabs explicitly, and then eliminating the lot.
  • Instance methods that explicitly take self feels awkward to me.
  • Static Methods that require an incantation such as "ToAbsoluteUrl = staticmethod(ToAbsoluteUrl)" also feels pretty awkward. (Ed: staticmethod can be used as a decorator which is much nicer)
  • The casting to delegate isn't quite as slick as it is in C#. Passing in "spiderTracker.FoundUrl" instead of "lambda url: spiderTracker.FoundUrl(url)" results in an extremely unhelpful runtime error.
  • The lambda syntax is pretty elegant, but so is C#3's. Indeed, C#3 seems to have the edge.
  • Python's regular expressions are powerful, but not quite as good as .NET's. In particular search does what you'd expect match to do
  • findall doesn't return matches. Rather, it returns the value of the first group of the matches. This is often actually what you wanted, but it's a bit peculiar. The semantics of "Matches" in .NET are much easier to understand.
  • It did seem rather slow compared to the C# version. There are, of course, way too many variables here to make a final judgement, but it was disappointing.
He does have some quibbles with the error reporting. He's posted some screenshots of particularly crpytic tracebacks:

by Fuzzyman (noreply@blogger.com) at September 26, 2008 01:53 PM

IronPython URLs

Surprised While Porting to IronPython 2

Ronnie Maor has blogged about his experiences of porting an IronPython 1 codebase to IronPython 2. The biggest change of course is the hosting API - which has changed completely. From the inside it is "just Python" and so the only changes should be fewer (and different) bugs. However, there are few subtle changes - like the ordering of essentially unordered collections like the dictionary and set - that revealed "hidden assumptions" in his code and tests:
My conclusions from this are:
  1. If it's not tested it doesn't work. And when you change the environment under which your code runs you need to retest.
  2. The unit tests paid off again, since they allowed me to find many problems in places I didn't expect.
  3. I need to do more to flush out these hidden assumptions. One way is to add a randomized test that runs over longer periods and plays with some variables. I could easily randomize the order in which I go over the checks, inject random errors (the system is supposed to be self healing) or delays in some strategic points, etc. The not-so-easy part is verifying the system behaved correctly, and being able to reproduce problems once they surface.
  4. Would be really good if I had code coverage tools. Don't think there's anything available for IPy :-(
  5. This happens every time I port non-trivial code. Need to stop being surprised :-)

by Fuzzyman (noreply@blogger.com) at September 26, 2008 01:36 PM

September 25, 2008

IronPython URLs

Assorted Snippets

Here are a collection of recent blog entries that feature IronPython but don't quite qualify for an IronPython-URLs entry of their own.

Starting with two new pages on the IronPython Cookbook:
A short recipe by Davy Mitchell that ensures user input is valid as a possible filename, removing invalid characters.
An entry by Dan Eloff demonstrating performance profiling for IronPython Silverlight applications.

Steve Gilham has been doing some odd things. Notably creating Java libraries in Java and Scala and then running them on .NET using the IKVM cross-compiler. I haven't been tracking them on this blog because most of the experiments have only been tangentially related to IronPython, but his latest entry is interesting. Here he is writing Scala (a very statically typed language for the Java Virtual Machine) code and using it from IronPython:
Which of course begs the question why?... it's still cool though.

UPDATE: In a new post Steve attempts to answer my question as to why he is doing this (and corrects my assumption that he is using IKVM to cross-compile Scala): Why am I doing this sort of thing?

Mitch Barnett has produced a promotional video (complete with rousing soundtrack) for his web based IronPython / DLR IDE the Global System Builder:

by Fuzzyman (noreply@blogger.com) at September 25, 2008 07:39 PM

IronPython URLs

Should Python Projects Support IronPython and Jython?

The maintainers of the Spring Framework for Python (Spring Python) wonder how much of a priority it is to have compatibility with platforms other than CPython. In other words, should they support IronPython and Jython - and if so what should they do about their C extension dependencies?

This question sparks a good discussion and is relevant to many other Python projects and applications:
"One of the topics on my mind recently, as we consider refactoring the core container, is how we ensure that when we introduce internal dependencies, such as possibly the Amara libraries for XML processing, what secondary constraints we might be introducing."

"For example, Amara represents a very pythonic and therefore simple to read and use approach to developing XML processing, such as our very own XML application configuration parsers. So from that perspective, things are very attractive. But then you ask the question, "can I run this on another python platform, such as IronPython and Jython?" and things get more constraining."

"However, my question is "is this important, in this case?" It's a general question for the Spring Python community really. Should we attempt to support the execution of SP applications on other platforms than CPython?"

"My feelings right now are that it is unlikely that a Spring Python application developer would expect to take their entire application as is and expect to run it on a different platform, such as .NET or Jython in the JVM. If I was going to do that, I would want to take advantage of the bits and pieces that are there in the .NET and Java worlds, and that would mean a port. It's also unlikely that I would necessarily get a business requirement to shift platforms like that... but I'm open to arguments there."

"My take is that Spring.NET provides Spring for the .NET community. Spring Java, well, it does the same for the Java community. Spring Python is doing the same for the Python community. The programming model and approach is portable, but it's not expected that the actual codebase is. Think of this as the concepts are the same, but exactly how you implement them would take full advantage of the platform you are on."

"So is this fair? This is where I need the community to chime in. Are my assumptions here wrong? Is there a defined need, special to the Python community, to come up with a framework that is truly portable at the implementation level, or is the goal really to create a framework that helps us use Spring concepts in the Python world. It's a BIG question, because it informs many of the core containers development choices, hence I thought it was time to get it out there for everyone to have their say."

by Fuzzyman (noreply@blogger.com) at September 25, 2008 06:09 PM

IronPython URLs

Running Python from C#

Mark Bloodworth (a Microsoft Architect Evangelist no-less!) posts a code snippet showing how to execute Python code from C# with the IronPython hosting API:
Embedding IronPython in .NET applications (or even embedding new Python engines in IronPython applications) is extremely simple to do. This means that providing user scripting, or even making part of an application dynamic, is much easier than it ever has been.

Mark says:

"I’m impressed that C# and IronPython can interact like this. The possibilities for extending applications with runtime dynamic code are intriguing - worth looking into."

by Fuzzyman (noreply@blogger.com) at September 25, 2008 12:32 PM

September 24, 2008

John Lam on IronRuby

The Fukuoka Ruby Delegation

Me with the Delegation from Fukuoka, Japan at the EBC

I had the honor of meeting with a delegation from Fukuoka, Japan this morning at Microsoft's Executive Briefing Center. Part of the delegation represents the Ruby Business Commons, one of the largest Ruby SIGs in Japan (> 500 people as of August 2008). They were here to talk to us about Ruby, its impact in Fukuoka, and how we can work together to help promote Ruby and IronRuby in the IT industry in Fukuoka.

It was a challenging meeting since everything had to be done through a translator (who did a remarkable job). They had some great questions and suggestions for how we can work together to help promote Ruby in the Enterprise in Japan. I'm looking forward to seeing what we can do together to help spread the love.

by John Lam at September 24, 2008 11:46 PM

IronPython URLs

NWSGI 0.5 Released

Alongside the new IronPython / ASP.NET release is progress with another web framework for IronPython - NWSGI.

NWSGI is a .NET implementation of the Python Web Server Gateway Interface specification. It is implemented as an ASP.NET HttpHandler with the goal of allowing you to run Python web applications / frameworks (such as Django, Trac etc) with the IIS 7 web server.

This latest release is version 0.5 and has a couple of new features and breaking changes. Jeff Hardy announces and explains the release on his blog:
Jeff also outlines his plans for the future of NWSGI:

"I'm working on building an IIS7 admin interface for all of this; it's a bit of a mess right now because the advanced UI tricks aren't really documented that well. I'm hoping to have the IIS7 admin and the installer ready by the time IronPython goes 2.0."

by Fuzzyman (noreply@blogger.com) at September 24, 2008 09:46 PM

IronPython URLs

IronPython and ASP.NET Integration Updated

The IronPython ASP.NET integration has been updated! The new home for "ASP.NET Dynamic Languages Support" is the ASP.NET Codeplex page:
Jimmy Schementi (responsible for the Dynamic Languages and Silverlight integration but who has also worked on this project along with David Ebbo and Phil Haack) is excited and invites you to join the party:
The new refresh includes support for using IronPython with 'normal' ASP.NET (webforms - but now updated to IronPython 2) and with the new ASP.NET MVC framework. For the MVC framework, IronPython is currently only integrated into the Views and not yet Controllers or Models.

There are samples plus documentation available and Jimmy's blog entry walks through creating an IronPython webforms site with Visual Studio.

Phil Haack, who is now PM for the ASP.NET Dynamic Language Support along with ASP.NET MVC, has also blogged about the new release:
This initial release targets IronPython first - IronRuby support will follow soon...

At least one Python blogger is excited by the news. Alcides Fonseca says:

by Fuzzyman (noreply@blogger.com) at September 24, 2008 09:45 PM

Miguel de Icaza

Love World Domination!

Chris Anderson is wearing a Mono T-Shirt on this PDC interview and IronRuby.com is hosted on DekiWiki, a Mono-powered Wiki site.

This is clearly awesome.

In other news, the awesome hackers at Imendio have officially released Gtk+ for OSX packages.

by Miguel de Icaza (miguel@gnome.org) at September 24, 2008 08:32 PM

Miguel de Icaza

Stream.CopyStream

Funkists, why does System.IO.Stream not have a CopyStream method, it seems like everyone ends up implementing this.

Discuss.

by Miguel de Icaza (miguel@gnome.org) at September 24, 2008 06:56 PM

The Voidspace Techie Blog

itemgetter and attrgetter

I've just discovered the attrgetter and itemgetter functions from the Python standard library operator module (both functions new in Python 2.4 with added functionality in Python 2.5). I wish I'd discovered them earlier as although they do very simple jobs they can make code cleaner and more readable. ... [569 words]

September 24, 2008 11:54 AM

Jimmy Schementi

ASP.NET Dynamic Language Support Refreshed!

party_time_top

Today, the IronPython team and the ASP.NET team released ASP.NET Dynamic Language Support on the ASP.NET Codeplex site!

 

Download it here!

 

Package

ironpython-webforms-sample.zip: running IronPython ASP.NET website. Either dump this in IIS or open with Visual Studio as a website project.

ironpython-mvc-sample.zip: and IronPython ASP.NET MVC website, so you can get a feel for how dynamic languages can integrate into MVC. However, this just shows IronPython working in Views, not Controllers or Models yet. This requires MVC to be installed to open the project in Visual Studio. Open it with Visual Studio, build, and run your shiny IronPython ASP.NET MVC app.

aspnet-dlr-docs.zip: Documentation on how to use all this stuff. Open intro.html and have fun. :)

 

Many Thanks!

This is a project that me, David Ebbo, and Phil Haack have been working on for a bit, and I'm so happy that the ASP.NET team is taking the DLR and committing to making dynamic languages work well on ASP.NET. Phil actually announced this on his blog as well, and I'm sure will be talking about this much more in the future. In short, a big thanks to David and Phil for getting this project kick-started again.

 

Walk-through: WebForms

Back in June I talked about this day coming, but I didn't even have a piece offering, other than my whit. To make up for that, I'm going to walk you through using IronPython in ASP.NET.

Note: I'm going to walk you through using Visual Studio to open the website and make changes. However, you can simply drop this directory into your IIS wwwroot and simply edit the files with a text-editor of your choice.

1. Extract ironpython-webforms-sample.zip, open Visual Studio, and then open a website project (File > Open > Web Site ...). Navigate to where you extracted the webforms sample, and click open; now you should see the following.

merlinweb-start

2. Take a look at the code in Default.aspx and Default.aspx.py. The aspx page has a asp:Literal control, with the id "messageLiteral", and the py file sets the text of that asp:Literal control.

<!-- Default.aspx -->
<%@ Page Language="IronPython" CodeFile="Default.aspx.py" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:Literal id="messageLiteral" runat="server" />
        </div>
        </form>
    </body>
</html>
# Default.aspx.py
def Page_Load(sender, e):
    messageLiteral.Text = "Hello Dynamic World!"

3. Hit Ctrl+F5 (Start without debugging), and the app will run. If you are not using Visual Studio, simply navigate to Default.aspx in your web browser.

merlinweb-hello-dynamic-world

4. Awesome, our app runs! Now let's make it do something. Replace the inside of the <div /> with a Label, TextBox, and a Button control (Note: you can also open the Toolbox in Visual Studio and drag these in).

Enter your name: <br />
    <asp:TextBox ID="TextBox1" runat="server">
    </asp:TextBox>
    <asp:Button ID="Button1" runat="server" Text="Button" />
    <br /><br />
    <asp:Label ID="Label1" runat="server" Text="Label">
    </asp:Label>

5. Open Default.aspx.py and change the Page_Load method to be the following:

def Page_Load(sender, e):
    if not IsPostBack:
        Label1.Text = "...Your name here..."

6. Now add the following code to Default.aspx.py to handle the button's Click event:

def Button1_Click(sender, e):
    Label1.Text = Textbox1.Text

7. Switch back to Default.aspx.py and make the Button handle the event:

<asp:Button ID="Button1" runat="server" Text="Button"
     OnClick="Button1_Click"/>

8. Now navigate back to your browser, and refresh the page. Enter any text in the textblock, click the button, and it'll appear in the label below.

merlinweb-name

Yeah, I know, not very useful, but it gives you an idea of how things work. Look through the "ASP.NET Dynamic Language Runtime Support Documentation" on the downloads page for more walk-throughs with IronPython and ASP.NET WebForms.

 

Go make awesome stuff!

I'm so happy that this finally got out, so hopefully I'll hear about people starting to use IronPython in ASP.NET much more. Consult http://codeplex.com/aspnet for any questions about roadmap or tutorials, and feel free to ask me questions as well.




by Jimmy Schementi (noreply@blogger.com) at September 24, 2008 01:21 AM

September 23, 2008

IronPython URLs

Passing Keyword Args to C# Methods from IronPython

Python has very useful constructs for accepting variable number of positional and keyword arguments:

def f(*args, **keywargs):
pass

The arguments are collected as a tuple and a dictionary. C# can collect an arbitrary number of arguments to a method (no messy functions in this language!) as an array (with the params keyword) - but it has no concept of keyword arguments let alone collecting them as a dictionary.

In this blog entry Srivatsn (IronPython tester) introduces the 'ParamDictionaryAttribute' that is part of the Dynamic Language Runtime ane explains how to use it to write C# classes that can take arbitrary number of keyword arguments:

by Fuzzyman (noreply@blogger.com) at September 23, 2008 03:54 PM

IronPython URLs

Game Scripting in IronPython

Calbert has written a MUD type game with C# and IronPython on the server, with the user interface in Silverlight.

"I wanted to explore this scripting for Perenthia because I want to be able to add dynamic functions or scripts to objects. I wrote this sample to test out using C# as base classes for IronPython classes and passing operations back and forth between the two. As such the source is kind of loose but the concepts are demonstrated.

What I have is a basic framework of C# classes that define an Actor (any object in the game), a Client (a connected player), a Game (the logic of the game) and a Server (for handling HTTP communication, etc.). The Actor, Client and Game classes also server as the base classes for IronPython classes or Creatures, NPCs, Players and Rooms."

In his blog entry he shows some of the C# classes and how they are used from IronPython.

by Fuzzyman (noreply@blogger.com) at September 23, 2008 03:36 PM

Jeff Hardy's Blog (NWSGI)

NWSGI 0.5 Released

The latest version of NWSGI, built for IronPython 2.0 Beta 5, has been posted. There are a couple of changes in this version: one breaking change and one new feature.

Configuraton Changes


To fit with convention, the configuration elements now start with lowercase letters - i.e. Wsgi => wsgi, OSEnviron => osEnviron, etc. This has a consequence because XML is case-sensitive, so the old configuration elements will not be picked up and the defaults will be used instead.

Script Mappings


Script mappings can be used to create a virtual .wsgi file that points to a file elsewhere on the filesystem. For example:


<scriptmappings>
<scriptmapping scriptname="dispatch.wsgi" physicalpath="C:\myapp\dispatch.wsgi">
</scriptmappings>


Rather than copy the dispatch.wsgi file into the web aplication directory, any request to dispatch.wsgi will be mapped to c:\myapp\dispatch.wsgi instead. This example is a bit trivial, as an IIS virtual directory could probably be used, but it could be useful for any application that ships a .wsgi file.

Future Directions


I'm working on building an IIS7 admin interface for all of this; it's a bit of a mess right now because the advanced UI tricks aren't really documented that well. I'm hoping to have the IIS7 admin and the installer ready by the time IronPython goes 2.0.

by jdhardy (jdhardy@gmail.com) at September 23, 2008 03:45 AM

September 22, 2008

IronPython URLs

DLR Namespace Change Fire Drill

The other significant change in IronPython 2 Beta 5 was a namespace change for one of the core assemblies: Microsoft.Scripting.Core.dll

At the heart of the Dynamic Language Runtime are expression trees - the Abstract Syntax Trees of DLR languages. Another part of the .NET framework (at least since .NET 3.5) is LINQ - Language Integrated Query. LINQ makes querying a first class language concept. In its most basic form (over objects) it resembles Python list comprehensions and generator expressions. With the right providers you can also use LINQ to query XML and databases - with your LINQ expressions being 'compiled' to SQL or an appropriate query language.

LINQ expression trees represent query expressions. In IronPython 2.0 Beta 4 the DLR expression trees merged with LINQ expression trees and were moved into the same namespace.

Unfortunately this caused name collisions all over the shop and made it virtually impossible to use IronPython or the DLR in projects that also used .NET 3.5 (particularly for ASP.NET projects). To resolve this problem the names have been moved again.

Harry Pierson explains the issues and the solutions:
The DLR Hosting blog summarises it more succintly:

"The recent beta release of the DLR allows the usage of LINQ and other CSharp 3.0 features in an application that hosts the DLR."

by Fuzzyman (noreply@blogger.com) at September 22, 2008 08:16 PM

IronPython URLs

IronPython 2.0 B5 - New Hosting API

For those interested in embedding IronPython in .NET applications there were two significant changes in IronPython 2 Beta 5. As this is the last beta before the release candidate, integrating this release should be the last changes you need to make.

The first change is that a significant portion of the hosting API has changed - and for some (but not all) use cases got a lot simpler.

Embedding Dynamic Language Runtime engines (what we are discussing here is the DLR hosting API) uses the App.Config file to configure the languages they intend to use. This part is probably more complicated than before. The DLR Hosting blog has a self-contained Visual Studio 2008 sample demonstrating how it works:
For languages like IronPython and IronRuby, convenience classes have been added that make hosting simpler. For IronPython the class is called Python. You can create a ScriptRuntime (one of the core hosting classes) without using the config system.

The DLR Hosting blog shows the basics:
Srivatsn (an IronPython tester) also has a blog on the subject - showing more of the convenience methods on the Python class. These include easy ScriptEngine creation and easy access to the builtin, sys and clr modules for an IronPython engine:
Srivatsn demonstrates pulling out builtin Python functions and calling them from C# - a useful technique for using dynamically created Python objects from other .NET languages.

by Fuzzyman (noreply@blogger.com) at September 22, 2008 07:51 PM

September 21, 2008

The Voidspace Techie Blog

Python: Two Phase Object Creation

I've started watching a talk by Alex Martelli on Python and design patterns: Google Tech Talk: Advanced Topics in Programming Languages Series It's very interesting. Alex points out that design patterns can't be taken out of the context of the language (the technology) in which they are being used. ... [766 words]

September 21, 2008 12:21 PM

IronPython URLs

Ironclad 0.6 Released and numpy in Resolver One

Since I last updated this blog (yes I've fallen behind in the last couple of weeks - I'll catch up soon) a lot has happened with Resolver One.

Resolver One is a spreadsheet development environment created by Resolver Systems and built on IronPython. Version 1.2 was released not long ago.

This includes several major new features, including one called 'RunWorkbook' that greatly helps with our goal of making spreadsheet system design modular, maintainable and resusable.

Part of our plan for Resolver One includes being able to use numpy (a C extension). At PyCon UK William Reade demonstrated working with numpy arrays containing one million items from inside Resolver One. This was using an experimental version of Resolver One ported to run on IronPython 2, along with Ironclad - our open source project that allows you to use Python C extensions from IronPython.

The Resolver Systems blog includes links to the slides for Giles Thomas's PyCon UK talk and William's lightning talk showing numpy with Resolver One.
William is the core developer for Ironclad and he has just announced the release of Ironclad 0.6. It is now based on IronPython 2 Beta 5 and a useful subset of numpy 1.2 RC 1 is importable and usable.

From the announcement by William:

I'm very happy to announce the release of Ironclad v0.6, which targets the recent release of IronPython 2.0b5. It's now possible to import the current release candidate for NumPy 1.2, and some of it actually works. Yay!

If you're interested, please download it and try it out; I'm very keen to hear everyone's experiences, both with NumPy and with other C extensions. I'm fully prepared for the fact that most of these will take the form of extremely short narratives along the lines of "I couldn't import foo", or "I did X, and then Y, and then it gave me the following error", but the project is now mature enough that it's *possible* that someone will say "I imported bar, and it kinda worked". That would, of course, make me tremendously happy, so I feel it's worth a try. In the absence of outside feedback, I will continue to work on NumPy; I get the impression that matrices would be widely useful, so they're my next target.

If you're interested in using numpy from IronPython, then download the latest release and tell us which bits don't work!

by Fuzzyman (noreply@blogger.com) at September 21, 2008 10:52 AM

IronPython URLs

Custom Fixed Size ListBox Items in IronPython in 30 Seconds

Ross was one of the developers who attended our IronPython tutorial at PyCon UK. Prior to the tutorial he was experimenting with Windows Forms. This recipe is a snippet of code for drawing fixed height custom listbox items (by handling the 'DrawItem' event):
From another blog entry, he comments on working with Windows Forms from IronPython:

"One thing I did notice whilst playing with IronPython and System.Windows.Forms was how relevant any S.W.F. experience you already have is likely to be. Yes, you’ll be writing a lot less code, but apart from the fact you’re using a much nicer language, the way that the UI works is obviously the same - which for some reason wasn’t as obvious to me as it should have been."

by Fuzzyman (noreply@blogger.com) at September 21, 2008 10:45 AM

IronPython URLs

REMLOG and the Dynamic Languages Braintrust

Dave Remy is the uber-commander-in-chief of the dynamic languages at Microsoft, and he blogs.

If you've ever wondered what the dynamic language team members look like, Dave has some photos of them from a lunch meeting with the 'brain-trust':
He also got together with Mike Vincent, who is "on the Board of Directors of INETA (International .NET Association) which works to coordinate a huge community of .NET user groups".

INETA is in touch with a large community of .NET developers:

"It appears INETA has great momentum, with greater than 250 active user groups and over 100,000 active developers in North America, and a reach of approximately 1.2 million developers world-wide."
"One question we asked was how important Mike saw Visual Studio Integration for the Iron languages. We get feedback at times that it is more important to have a lightweight, quick to bring up, quick to close down, editor for script editing than full VS integration. Others tell us, make sure that we integrate well with VS now since this is their primary code editing tool. Mike’s response was that VS integration is “a big deal” for adoption by the mainstream .NET developer and consequently a must have."

by Fuzzyman (noreply@blogger.com) at September 21, 2008 10:35 AM

September 20, 2008

IronPython URLs

Embedding Boo and IronPython

Nahum Dotan has been trying to evaluate which of Boo and IronPython are more suitable for embedding. (Boo is a statically typed .NET / Mono programming language with duck typing and a Python inspired syntax.)

"In short, I didn’t come to a conclusion.

But I did have some fun. I played with the thought that using python’s native dictionary initialization syntax would be nice as a configuration file syntax (e.g. ini files).

So I whipped a sample project that would embed both Boo and IronPython and looked at the differences with usage. So far I’m liking IronPython better.

This example is ridiculously simple, but you can go ahead and tinker with the engines, its a good timekiller."

by Fuzzyman (noreply@blogger.com) at September 20, 2008 08:39 PM

IronPython URLs

IronPython Bugs

No, this entry isn't about bugs in IronPython - it's about two blog entries by Dave Fugate (an IronPython tester) on the processes around fixing bugs in IronPython.

The IronPython issue tracker is hosted on Codeplex. The tracker is triaged weekly to review new bugs and Dave explains the different factors involved in assigning bugs to releases.
In his next entry, Dave explains the best way to get your bug report noticed and fixed: Getting Your IronPython Bugs Fixed Quickly
  • Use the bug template when reporting on CodePlex
  • Emphasize if the bug blocks an application
  • Email the list as well
  • Provide the simplest repro possible

by Fuzzyman (noreply@blogger.com) at September 20, 2008 08:33 PM

DLR Hosting and related stuff...

Using LINQ and the DLR in the same application

The recent beta release of the DLR allows the usage of LINQ and other CSharp 3.0 features in an application that hosts the DLR. Harry, our IronPython PM has a detailed post explaining why this was not possible before and whats changed now.

by seshadripv at September 20, 2008 02:36 AM

September 19, 2008

IronPython URLs

A Time Tracking Tool, IronPython Learnings & Google Authentication

Joseph Jude has been learning IronPython. He's created a time tracking tool, which tracks how long you use different applications on your PC. He's also posted a blog entry about learning IronPython.

This entry covers the tools he uses and some of the problems (with solutions) that he encountered:
He has also made his 'time tracking tool' available for download:
While I was waiting for Django 1.0 to be released, I wanted to quickly learn to develop desktop applications. I preferred it to be on Python so that I can continue to learn the language. I did an evaluation of different options and settled on IronPython.

As a consultant, there is always a need to submit timesheets. By the end of the day/week, it is difficult to remember the tasks done during that time-span (day/week). If somehow a tool can capture applications that were worked on, then it will help.

This application polls the active window at an interval of 5 seconds and captures the application details (application name and the application title) and the time spent on each of these tasks. It can be minimized into systray so that it can continue to capture details without any disturbance (first icon). One can download the details on the grid as a csv file too.

In his very latest blog entry Joseph has been exploring doing google account authentication for desktop applications. He uses the Google AppEngine to do the authentication and shows code for communicate with the web app (a Django app) from both 'normal Python' and IronPython (using the .NET web libraries):

IronPython Desktop Application will pass userid, password to AppEngine Application, which in turn will validate with Google Accounts Authentication service. If authenticated, AppEngine application will proceed; else it will pass the error back to the desktop application.

by Fuzzyman (noreply@blogger.com) at September 19, 2008 01:24 PM

IronPython URLs

Simple IronPython Example Using XML, Oracle and SQL Server

From the "Head Above The Clouds Blog":

This is an IronPython example of using .NET classes to load a XML document, query it with a simple XPath expression, and then using the results to transfer data from an Oracle to a SQL Server database.

by Fuzzyman (noreply@blogger.com) at September 19, 2008 11:01 AM

September 18, 2008

IronPython URLs

IronPython 2.0 Beta 5 Released

IronPython 2 Beta 5 has just been released. IronPython 2 is an implementation of Python for Mono and the .NET framework and is built on top of the Dynamic Language Runtime.

IronPython 2 Beta 5 is intended to be the last beta before the release of IronPython 2 final (although there will probably be at least one release candidate) - so if you want bugs fixing now is the time to test and report them!
    <