[IronPython] Exporting Python code as an assembly

Curt Hagenlocher curt at hagenlocher.org
Mon Feb 4 20:01:21 CET 2008


The assemblies call into the IronPython engine (version 2) to load and
execute the script.  Currently, the script is loaded from the file system,
but I'd eventually like to support embedding any required scripts
as resources in the assembly, so that the whole thing can be distributed as
a single neat package.

On Feb 4, 2008 10:55 AM, Michael Foord <fuzzyman at voidspace.org.uk> wrote:

> The interface is pretty much exactly what I had in mind for a similar
> system.
>
> What do the statically defined assemblies do - do they call into the
> IronPython engine - and if so, for IronPython 1 or 2? If not then are
> you just compiling Python to static assemblies?
>
> To my mind the former is more interesting than the latter... (Although
> both are interesting of course...)
>
> Michael
> http://www.manning.com/foord
>
>
> Curt Hagenlocher wrote:
> > After a bit of spare-time hacking this weekend, I've got a
> > "proof-of-concept" program that takes a Python class and exports it as
> > a (statically-defined) assembly.  It uses Pythonic function
> > annotations to signal attributes and input and output types to the
> > wrapper generator.  You end up with something like this
> >
> > def Test(object):
> >     @ClrAttribute(Xunit.FactAttribute)
> >     def WorthlessTest(self):
> >         Xunit.Assert.Equal[type(1)](1, 1)
> >
> >     @ClrAccepts(System.String, System.Int32)
> >     @ClrReturns(System.Int32)
> >     def CalculateValue(self, s, i):
> >         return len(s) + i
> >
> > The program takes this source and spits out a DLL containing the class
> > "Test" which implements "WorthlessTest" and "CalculateValue".  The
> > class itself contains a reference to the actual Python object, and
> > each of the public functions simply delegates to the Pythonic
> > implementation.
> >
> > I'm still working on cleaning up the source a little before releasing
> > it, but was wondering if anyone had some feedback on the design as
> > described so far.  What should be changed or implemented in order for
> > this to be more useful to you?
> >
> > Thanks,
> > -Curt
> >
> > --
> > Curt Hagenlocher
> > curt at hagenlocher.org <mailto:curt at hagenlocher.org>
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > Users mailing list
> > Users at lists.ironpython.com
> > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> >
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20080204/a4f38f5c/attachment.html>


More information about the Ironpython-users mailing list