栏目分类:
子分类:
返回
文库吧用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
文库吧 > IT > 面试经验 > 面试问答

py2exe的跨平台替代方案

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

py2exe的跨平台替代方案

好的,我已经做到了。这有点hacky,但是对于我的用例来说效果很好。

要点是使用ModuleFinder查找所有导入的模块,过滤掉所有系统模块,编译并压缩它们。

不幸的是,我的代码杂乱无章,与这个问题没有任何关系,因此我无法粘贴一个工作程序,仅粘贴一些片段:

zipfile = ZipFile(os.path.join(dest_dir, zip_name), 'w', ZIP_DEFLATED)sys.path.insert(0, '.')finder = ModuleFinder()finder.run_script(source_name)for name, mod in finder.modules.iteritems():    filename = mod.__file__    if filename is None:        continue    if "python" in filename.lower():        continue    subprocess.call('"%s" -OO -m py_compile "%s"' % (python_exe, filename))    zipfile.write(filename, dest_path)


转载请注明:文章转载自 www.wk8.com.cn
本文地址:https://www.wk8.com.cn/it/640094.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 wk8.com.cn

ICP备案号:晋ICP备2021003244-6号