views:

212

answers:

3

Does anyone know how to add python and ruby libs as a resource in a dll for deployment? I want to host a script engine in my app, but dont want to have to deploy the entire standard libraries of the respective languages in source files. Is there a simple way to do this so that a require or import statement will find the embedded resources?

A: 

You can create StreamContentProviders for example

In the ironrubymvc project under IronRubyMVC/Core/ you will find what you need.

AssemblyStreamContentProvider

Usage of the ContentProvider

Casual Jim
A: 

IronPython 2.0 has a sample compiler called PYC on Codeplex.com/ironpython which can create DLL's (and applications if you need them too).

IronPython 2.6 has a newer version of PYC under Tools\script.

Cheers, Davy

daftspaniel
+1  A: 

You could add custom import hook that looks for embedded resources when an import is executed. This is slightly complex and probably not worth the trouble.

A better technique would be to fetch all of the embedded modules at startup time, execute them with the ScriptEngine and put the modules you have created into the sys.modules dictionary associated with the engine. This automatically makes them available for import by Python code executed by the engine.

fuzzyman