从Python文件创建.dll [英] Creating .dll from a Python file

查看:449
本文介绍了从Python文件创建.dll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

py2exe生成dll吗?

我正在寻找一种方法从python文件制作.dll文件。我还想知道是否可以从C ++ oder汇编程序之类的另一种语言使用dll中的函数?
我一直在查看py2exe和pyapp,但它不提供到dll的移植。

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.

对此问题感到抱歉。我感到抱歉,因为我之前没有在StackOverflow中搜索类似的问题/可能的重复项。

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

推荐答案

您可以将多个python脚本编译成

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

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

这是IronPython,但要从其他语言中引用这些模块(例如.C ++或C#)在我看来,IronPython会更可取,因为它作为.NET解释器运行,其他实现.NET的语言也可以理解。

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

另一个IronPython脚本中的dll,例如:

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

import clr
clr.AddReference("modules.dll")

这篇关于从Python文件创建.dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆