Posts

Showing posts with the label library

NumPy and SciPy for IronPython and .NET

The genius of IronPython is that it provides great integration with .NET libraries. The cost of this is that you no longer have access to Python extensions implemented in C unless the IronPython team, or a third party, has created an equivalent version in C# or wrapping an existing .NET library. One very powerful and widely used set of Python extensions come in the form of NumPy and SciPy . This is a particular problem for those interested in IronPython as there is nothing of equivalent functionality and quality in the .NET world. There is an existing way of accessing Python C extensions from IronPython in the form of Ironclad . Ironclad was specifically designed to work with NumPy, and it works astonishingly well, but it can never be as good as a native library. Microsoft are obviously very interested in NumPy as they have just announced an interesting partnership with Enthought , a company who are active in the Scientific Python community. The partnership is specifically to br...

adodbapi 2.3.0 (the django version) released

Vernon Cole has announced the release of a new version of adodbapi, a Windows database driver that works with both CPython and IronPython.   This version is all about django support.  There are two targets:     A) MS SQL database connections for mainstream django.     B) running django on IronPython    Thanks to Adam Vandenberg for the django modifications. adodbapi home page on sourceforge A Python DB-API 2.0 module that makes it easy to use Microsoft ADO for connecting with databases and other data sources using either CPython or IronPython. This version is highly refactored following the work of Adam Vandenberg, and also has all of the current user suggested patches. Both the Mercurial tree and the downloadable zip files are updated.  (There is no fancy installer, just copy the folder in your site-packages folder.) This has been tested using CPython 2.3, CPython 2.6, IronPython 2.6 (.NET 2) and IronPython 2.6(.NET 4...

SQLite, zlib and XNA

Image
Jeff Hardy has been at it again, and has just done releases of both IronPython.SQLite and IronPython.Zlib - ports of the Python zlib and pysqlite modules to IronPython. IronPython: SQLite and Zlib IronPython.Zlib  implements the zlib module for IronPython using ComponentAce’s zlib.net, which is a purely managed implementation of the zlib library. IronPython.Zlib is entirely managed code and works with both 32-bit and 64-bit IronPython. It passes all of the Python 2.6 zlib and gzip tests and most of the zipfile tests. IronPython.SQLite is a port of pysqlite to IronPython using C#-SQLite, which, similar to zlib.net, is a managed implementation of SQLite. Thus, IronPython.SQLite is also 100% managed code. It passes about 87% of the Python 2.6 sqlite3 tests; the remaining ones are mostly corner cases or rarely used functionality. Carl Trachte also emailed me about a Japanese blog post on using XNA with IronPython. XNA is the Microsoft game creation framework that runs on the XBox...

A Good Mix 19: Reflection, the Silverlight Toolkit, Dynamic JSON, libraries, builds and more

A collection of blog entries and articles on IronPython and the Dynamic Language Runtime from the last few weeks. Speed Test: Reflection vs IronPython Randall Sutton was using reflection to apply rules to an object when he realised he could do it with IronPython, but he was worried about performance. He wrote a quick test to compare the performance and was surprised by the results. The first run was very expensive for IronPython, but from there on in IronPython was much faster than C#. Without expending any effort actually working it out, my guess is that because IronPython uses reflection so heavily it caches the reflection lookups - and it is this caching that is giving it the performance benefit. Reflection on .NET is not fast, by any stretch of the imagination, and improving the performance of reflection would make a big difference to speeding up DLR languages. The Silverlight Toolkit and the Dynamic Language Console The Silverlight Toolkit is an open source project by Microsoft ...

ZLIB and .NET

Steve Gilham has been involved in some odd experiments with a codebase involving IronPython, Jython and Scala (with Erlang occasionally in the mix as well). His latest post shows the IronPython code needed for ZLIB compression on .NET, even though it isn't provided directly by the framework: ZLIB and .Net A recurring problem in several of the projects I have in the pipeline is the matter of handling ZLIB. Java, though java.util.zip offers ZLIB compression with a 32k byte window (but no means of tuning the window) through the DeflaterOutputStream. The .Net framework doesn't offer direct ZLIB at all, but provides naked Deflate via System.IO.Compression.DeflateStream . That gives us enough to be able to reflate the output of a ZLIB deflation, since a ZLIB is a 2 byte header, a deflate section and finally a 4 byte checksum. That works fine; but the converse, taking a .Net deflate and adding the appropriate top and tail took a bit of getting to work. First pitfall -- the Inflater...

A Good Mix 4: NWSGI, AutoCAD, Another ctypes and C# in Depth

Another fine selection of IronPython related links for your delectation. NWSGI 1.1 Preview 1 NWSGI is " a .NET implementation of the Python WSGI specification for IronPython. It is implemented as an ASP.NET HttpHandler for use with IIS 6 and 7 " created by Jeff Hardy . The goal is to be able to run Python applications like Django, Trac and Pylons on IronPython. It can also be used on the Microsoft Azure (cloud computing) platform. This new release is a pre-release which depends on IronPython 2.6 Alpha 1 . The following features/changes have been added to NWSGI: Add " callable " attribute to scriptMapping to specify the callable for that script. Allow for "virtual" scripts by extending callables to allow for package.module:callable. This can avoid creating a .wsgi file in many scenarios. This can be used with wildcard mappings by specifying wildcardModule=":callable". Use the "debug" attribute on system.web/compilation instead of on ws...

Pygments for Windows Live Writer

Pygments is an extremely versatile Python library that does syntax highlighting. It not only supports many input languages , but can also output in many common markup formats (for wikis and so on). Windows Live Writer is a WYSIWYG Windows blogging tool by Microsoft. It allows you to write blog entries on your desktop (shock news - not everything needs to happen online), including adding images and videos. It integrates with blog services like Windows Live, Wordpress, Blogger, Live Journal, TypePad, and many more. I've never used it, but hear good things about it from developers I respect. Devhawk (Harry Pierson the Microsoft IronPython PM) uses live writer, and has written a plugin that uses IronPython and Pygments with a Windows Forms multi-line textbox as the code editor window. Pygments for Windows Live Writer Pygments for WL Writer is a smart content source. In WL Writer’s terminology, that means when you click inserted text in the editor window, it is treated as an atomic e...

Using Nose with IronPython

nose is a testing library for Python. nose is a popular alternative to unittest , which is part of the standard library, and boasts features like: Test autodiscovery Output capture Not restricted to class based tests Class and module level setUp and tearDown Assert introspection Test generators Plugin mechanism Personally I don't find the object oriented way of organising tests a problem; test methods grouped in classes seems very logical to me. I also like assert methods and the richer error messages they provide. I usually end up defining all sorts of convenience assert methods myself that do the heavy lifting of my testing anyway. I'm sceptical of the magic that libraries like nose and py.test do to provide some of the same information with bare asserts - and that magic doesn't work with IronPython anyway. The test discovery stuff is invaluable though. Whenever I create a new project I inevitably end up recreating some variation that does test discovery for the project...

Another Awesome Collection - IronPython Links

Another tab closing session - a lot of links to IronPython (etc) content here. There are a couple of interesting reports of Python libraries working with IronPython, but we start with an IronRuby article: .NET Interop: Getting Started with IronRuby and RSpec, Part 1 An excellent article by Ben Hall on testing .NET code (C#) with IronRuby and RSpec. In this article, I will introduce you to Ruby and IronRuby and demonstrate some basics of Ruby interoperating with Microsoft .NET Framework-based code. I also explain how frameworks such as RSpec can be used to generate examples of how objects are intended to behave, providing both documentation and verification that the system is built correctly. This will set the stage for a future article in which I will explain acceptance testing in detail and demonstrate creating acceptance tests with IronRuby. IronPythonの特徴 A Japanese article on IronPython. No idea what it says! Dynamic Language Runtime on Azure A demo of an Azure (Microsoft cloud pl...

Bridge, Kamaelia and XMPP on IronPython

Kamaelia is a Python concurrency library that uses Python coroutines (generators). Despite being pure Python it is powerful enough for streaming audio and video. Bugs in IronPython 1 prevented Kamaelia running on IronPython, but that doesn't seem to be the case for IronPython 2... Sylvain Hellegouarch has a Python library called headstock for communicating over XMPP: XMPP and IronPython 2 using headstock, bridge and Kamaelia For a while IronPython had severe shortcomings that prevented it running simple Kamaelia applications. Today I was able to run a simplechat demo using a vanilla IP2 on Windows with only one single modification to the logging module (thanks Seo). To be honest I didn’t expect it to go through :) The chat demo is simple enough but means more complex examples using XMPP PubSub will work as well (they are all based on the same framework). Now this isn’t production ready or anything. For instance the TLS support is broken (hopefully something easy enough to fix) so...

Jeff Hardy: Django, Zlib and easy_install on IronPython

Jeff Hardy is the creator of NWSGI , a .NET implementation of WSGI implemented as an ASP.NET HttpHandler for use with IIS 6 & 7. His goal is to be able to use Python web applications and frameworks like Django and Trac from IronPython. He has been working on getting Django and easy_install working with IronPython. For easy_install one of the big hurdles is that the zlib module isn't available (even the version in FePy is missing a key part of the API that setuptools uses to unpack archives it downloads from PyPI). Getting setuptools working with IronPython will be a big win for using Python libraries and frameworks as more and more of them depend on being installed in this way. He has written three blog entries on how far he has got with these issues. Django + IronPython I've had a couple of people ask about a Django + IronPython "Getting Started". This has been on my TODO list for a while; I just haven't gotten around to it. I'll try to do somethin...

The Chemistry Development Kit and IronPython

The Scientific C# blog looks at using another "mature open source cheminformatics api" from C# and IronPython: The java Chemistry Development Kit . Using the CDK with the .NET Framework and Mono As it is a Java library, using it from .NET is a novel idea... The blog entry shows you how to compile the library for .NET using IKVM , an implementation of Java for .NET. The command line magic to compile CDK for .NET is: ikvmc -assembly:cdk_dotnet -target:library yourcdkjar.jar This produces a .NET assembly. An example of using the library from IronPython: import clr clr.AddReference("cdk_dotnet.dll") clr.AddReference("IKVM.OpenJDK.ClassLibrary.dll") from org.openscience.cdk import Molecule from org.openscience.cdk.smiles import SmilesParser #import the whole package for brevity from org.openscience.cdk.qsar.descriptors.molecular import * from org.openscience.cdk.qsar.result import DoubleResult tpsa = TPSADescriptor() logP = XLogPDescriptor() smiles = SmilesPars...

OpenBabel from IronPython

Noel O'Blog reports on the recent OpenBabel release that explicitly supports IronPython. OpenBabel, IronPython and ADME filtering 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 ...