py2exe 生成dll? [英] py2exe to generate dlls?

查看:43
本文介绍了py2exe 生成dll?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法使用py2exe或其他方法来生成dll文件而不是exe文件?

Is there a way using py2exe or some other method to generate dll files instead of exe files?

我想基本上用普通函数创建一个普通的 win32 dll,但这些函数将用 python 而不是 c++ 编码.

I would want to basically create a normal win32 dll with normal functions but these functions would be coded in python instead of c++.

推荐答案

我认为你可以通过做一些黑客来解决这个问题:

I think you could solve this by doing some hacking:

  • 查看 py2exe 中的 zipextimporter 模块.它有助于从 zip 导入 pyd 文件.
  • 使用它,您可以使用原始 python-api 在您自己的应用程序/dll 中加载 py2exe 的输出文件.(如果可以并且愿意,请使用 boost::python)
  • 而且,由于 py2exe 的输出文件是一个 zip,您可以将它附加到 dll 的末尾,从而使整个文件更加集成.(旧技巧也适用于 jar 文件.)

未经测试,但我认为该理论是合理的.

Not tested, but I think the theory is sound.

本质上,您在 dll 中重新实现了 py2exe 的输出可执行文件的 main().

Essentially, you reimplement py2exe's output executable's main() in your dll.

这篇关于py2exe 生成dll?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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