Scott Holden
Scott Holden

Reputation: 396

Packaging script source files in IronPython and IronRuby

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?

Upvotes: 3

Views: 537

Answers (3)

fuzzyman
fuzzyman

Reputation: 8381

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.

Upvotes: 1

daftspaniel
daftspaniel

Reputation: 955

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

Upvotes: 0

Casual Jim
Casual Jim

Reputation: 1179

You can create StreamContentProviders for example

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

AssemblyStreamContentProvider

Usage of the ContentProvider

Upvotes: 0

Related Questions