py2exe 修改应用程序输出名称
我正在做我的第一个Python项目,需要用py2exe来编译。我写了这个setup.py的代码:
from distutils.core import setup
import py2exe
import sys
import os
if len(sys.argv) == 1:
sys.argv.append("py2exe")
setup( options = {"py2exe": {"compressed": 1, "optimize": 2,"dll_excludes": "w9xpopen.exe",'dist_dir': "myproject", "ascii": 0, "bundle_files": 1}},
zipfile = None,
console = [
{
"script": "myapplication.py", ### Main Python script
"icon_resources": [(0, "favicon.ico")] ### Icon to embed into the PE file.
}
],)
os.system('upx -9 dist/*.exe')
os.system("rmdir /s /q build")
os.system("del /q *.pyc")
这个设置代码是可以工作的,但我想把编译出来的应用程序的名字从myapplication改成project.exe。请问py2exe有什么选项可以改变输出应用程序的名字呢?
1 个回答
17
在你的控制台字典里添加 "dest_base" : "app_name"
,像这样:
console = [ { "script": "myapplication.py", ### Main Python script "icon_resources": [(0, "favicon.ico")], ### Icon to embed into the PE file. "dest_base" : "app_name" }]