我正在用Python 3.2和Pygame进行游戏。我已成功设法使用cx_freeze
将所有内容捆绑到可执行文件中,并运行。精细。唯一的问题是,即使当我将-OO
标志传递给我的setup.py
时,也会以调试模式编译我的游戏。(我已经print
声明证实,它是__debug__
确实True
。)Python 3.2:cx_freeze编译我的程序,但在调试模式下
的问题是,我的游戏已经调试是在释放模式自动禁用功能。我不想分发我的游戏的调试功能,我不希望手动将它们从代码中移除。
我setup.py
,这里缩短简洁,如下:
from cx_Freeze import setup, Executable
includes = [<some modules>]
excludes = [<some unwanted modules>]
include_files = [<game assets>]
build_options = {
'append_script_to_exe':True,
'bin_excludes':excludes,
'compressed':True,
'excludes': excludes,
'include_files': include_files,
'includes': includes,
'optimize':2,
'packages': ['core', 'game'],
}
common_exe_options = {
'appendScriptToExe' : True,
'appendScriptToLibrary':True,
'compress' : True,
'copyDependentFiles' : True,
'excludes' : excludes,
'includes' : includes,
'script' : '__init__.py',
}
executable = Executable(**common_exe_options)
setup(name='Invasodado',
version='0.8',
description='wowza!',
options = {'build_exe': build_options,
'bdist_msi': build_options},
executables=[executable])
完整的剧本,与我的代码的其余部分,可以在https://github.com/CorundumGames/Invasodado/blob/master/setup.py找到。
在Ubuntu 12.10上,我使用python3.2 -OO setup.py build
构建。在Windows XP上,我正在用C:\Python32\python -OO setup.py build
构建。
任何帮助将会很棒!
这是对OpenGL代码一个巨大的问题:东西像pyglet和pyopengl,如果我没有记错,在运行时,如果执行了一堆昂贵的安全检查不运行优化,将代码降低一个数量级。 – 2015-08-20 21:35:08