1

Possible Duplicate:
py2exe to generate dlls?

I'm searching for a way to make a .dll-file out of a python file. I also wonder if I can use the functions in the dll from an another language like C++ oder Assembler? I have been looking at py2exe and pyapp, but it doesn't provide porting to dll.

I'm sorry for this question. I feel sorry because I didn't search StackOverflow before for similar questions / possible duplicates .

Community
  • 1
  • 1
  • consider that any scripting language which is "compiled" must necessarily embed pretty much the entire interpreter inside that executable, especially if the script does any kind of `eval()` type stuff. it's even harder to componentize such a thing into a .dll – Marc B Nov 10 '12 at 23:54

1 Answers1

5

You can compile multiple python scripts into an assembly using clr.

import clr
clr.CompileModules("modules.dll", "module.py", "module2.py")

This is IronPython, but to reference these modules from other languages (ex. C++ or C#) IronPython would be preferable in my opinion because it runs as a .NET interpreter that can be understood by other languages that implement .NET

To reference the compiled dll from another IronPython script, for example:

import clr
clr.AddReference("modules.dll")
John
  • 2,675
  • 2
  • 18
  • 19