[py2exe] __debug__ = 0 - how?

F. GEIGER f.geiger at vol.at
Tue Jul 20 21:04:48 CEST 2004

Thomas Heller wrote:

> "F. GEIGER" <f.geiger at vol.at> writes:
>>I'd like to get rid of all __debug__ code fragments in my app. So I
>>have changed the invocation of python to python -O in Windows
>>Explorer. I use a wx.TextCtrl to display th e__debug__ flag:
>>if __debug__:
>>    text = "__debug__ = 1"
>>    text = "__debug__ = 0"
>>The control shows "__debug__ = 0" as expected.
>>When I build an exe file, __debug__ still seems to be on. Does py2exe
>>switch -O off again or doesn't the -O get thru to py2exe? If so, does
>>there exist a py2exe-option to switch on optimizing for exe files?
> You have to specify it for py2exe, it doesn't use the __debug__ from Python:
> C:\sf\py2exe\py2exe\samples\simple>setup py2exe -h
> Global options:
>   --verbose (-v)  run verbosely (default)
>   --quiet (-q)    run quietly (turns verbosity off)
>   --dry-run (-n)  don't actually do anything
>   --help (-h)     show detailed help message
> Options for 'py2exe' command:
>   --optimize (-O)    optimization level: -O1 for "python -O", -O2 for "python
>                      -OO", and -O0 to disable [default: -O0]
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>   --dist-dir (-d)    directory to put final built distributions in (default is
>                      dist)
>   --excludes (-e)    comma-separated list of modules to exclude
>   --ignores          comma-separated list of modules to ignore if they are not
>                      found
>   --includes (-i)    comma-separated list of modules to include
>   --packages (-p)    comma-separated list of packages to include
>   --compressed (-c)  create a compressed zipfile
>   --why              why is module <m> included
> usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
>    or: setup.py --help [cmd1 cmd2 ...]
>    or: setup.py --help-commands
>    or: setup.py cmd --help
> Thomas

Ouch, a plain RTFM, embarrassing...

Works now as expected. Thanks a lot, Thomas!

Kind regards

More information about the Python-list mailing list