[IronPython] Importing .py files embedded as resources (from Silverlight)

Jimmy Schementi Jimmy.Schementi at microsoft.com
Fri Jun 19 12:55:02 CEST 2009


No special support; you'll have to iterate over all the files as resources, get their contents, and do the following:

var scope = scriptEngine.CreateScope();
scriptEngine.CreateScriptSourceFromString(code).Execute(scope);

Though, why not just put the python files in the XAP? Then importing will just work, since the engine knows how to look in the XAP. If you're really hellbent on having them as resources, you could built a custom version of Microsoft.Scripting.Silverlight.BrowserPAL to look for files as embedded resources.

~js
________________________________
From: users-bounces at lists.ironpython.com [users-bounces at lists.ironpython.com] on behalf of Thibaut Barrère [thibaut.barrere at gmail.com]
Sent: Friday, June 19, 2009 12:37 AM
To: users at lists.ironpython.com
Subject: [IronPython] Importing .py files embedded as resources (from Silverlight)

Hello,

this is my first post here, so hi!

I'm currently porting some IronPython library I'd like to use from a C# or IronRuby Silverlight app. For that purpose, I'm creating a Silverlight C# library which embeds all the required .py files and try to compile/execute them at runtime.

Is there a built-in way of telling the IronPython engine that some resources are embedded in the dll ? Maybe some hooks to detect imports and return the stream of content for a given .py file ?

The IronPython library has multiple subfolders on several levels, for increased fun.

Should I iterate over all the available files and execute them in the same scope ?

Thanks for any insight when dealing with that kind of scenario,

cheers,

-- Thibaut
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20090619/1fe67616/attachment.html>


More information about the Ironpython-users mailing list