有没有办法从ironpython中的zip文件加载python脚本
我想要扩展用 IronPython 编写的应用程序。这些扩展的一部分将使用装饰器,因此我希望在包中包含 装饰器 模块。
问题是装饰器依赖于 IronPython 发行版中存在的几个模块,而这些模块又依赖于其他模块,等等。
最简单的解决方案是将整个 Lib 文件夹包含在应用程序中,但这会增加 500 个文件和 12 MB 的占用空间。
为了避免这种情况,我尝试压缩模块并从 zip 文件加载它们,而不是直接从文件系统加载,但我还没有找到一种简单的方法来执行此操作。
我发现了通过“path_hooks”全局加载模块的导入器机制,这似乎使我可以访问类似于 imp 机制,但我不知道如何使用它。
IronPython 中是否有我缺少的导入机制的钩子? 我应该如何实施这个?
I want to have extensions to my application written in IronPython. Part of those extensions will use decorators, and so I wish to include the decorator module in the package.
The issue is that the decorator depends on several modules existing in the IronPython distribution, and those modules depend on other modules and so on.
The easiest solution would be to include the entire Lib folder in the application, but that would increase the footprint by 500 files and 12 mb.
To avoid that I'm trying to zip the modules and load them from the zip file instead of directly from the filesystem, but I haven't found a straightforward way to do so.
I've spotted the importer mechanism for loading modules via a "path_hooks" global , which seems to give me access to something similar to the imp mechanism in Python, but I'm not sure of how to use it.
Is there a hook for the import mechanism in IronPython that I'm missing?
How should I go about implementing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您想要的是 zipimport 支持,尚未实现。如果您愿意帮忙,我可以让您与负责此工作的人员联系。
否则,看起来您可能只需要删除decorator.py 需要的inspect.py 的部分即可。
What you want is zipimport support, which isn't implemented yet. If you'd like to help out with that I can put you in touch with the guy who's working on it.
Otherwise, it looks like you might just need to stub out the bits of inspect.py that decorator.py needs.