473,385 Members | 2,003 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

[py2exe] __debug__ = 0 - how?

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"
else:
text = "__debug__ = 0"

etc.

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?

Kind regards
Franz GEIGER
Jul 18 '05 #1
2 2228
"F. GEIGER" <f.******@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"
else:
text = "__debug__ = 0"

etc.

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
Jul 18 '05 #2
Thomas Heller wrote:
"F. GEIGER" <f.******@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"
else:
text = "__debug__ = 0"

etc.

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
Franz GEIGER
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: RJS | last post by:
Hi all, I can't get a py2exe compiled app to run with numarray (numarray-0.5.win32- py2.2). Also wxPythonWIN32-2.3.3.1-Py22 and ActivePython-2.2.1-222. In the sample below, commenting out...
2
by: Stefan Behrens | last post by:
Hi, does anybody know how I can get py2exe to work with wxPython's wxCalendarCtrl? Currently, I have just a "standard" setup.py, and py2exe gives me a syntax error. Do I need to include any...
0
by: Kathleen Kudzma | last post by:
I'm having a problem with py2exe for Python 2.3. I got fixed the Lookuperror no codec search functions registered: can't find encoding by following the instructions on the py2exe page (added...
8
by: Kathleen Kudzma | last post by:
Does anyone know how to resolve the following problem that I'm getting in Python 2.2 and 2.3? PROBLEM: When I try to create a classReader object I get an exception: "SAXReaderNotAvailable: No...
0
by: Steven Bell | last post by:
I am trying to build an executable from a python script. Using python 2.3, SOAPpy 0.10.3, Py2exe 0.4.2. Build command: python setup.py py2exe -w --includes xml.sax.drivers2.drv_py I get the...
6
by: Luc Saffre | last post by:
Hello, I had a strange problem when freezing (using either py2exe or McMillan installer) a script that imports reportlab (which imports PIL (which imports FixTk))). - Python 2.3.3c (also with...
0
by: ago | last post by:
Hi all, When I use my win32com.server object from an excel client, the python process running the server always has __debug__==True. When using a python client the __debug__ flag for the server...
0
by: Larry Bates | last post by:
Jimmy Retzlaff wrote: Everyone, Thanks for all your hard work on py2exe, it is greatly appreciated. -Larry Bates
0
by: Jimmy Retzlaff | last post by:
py2exe 0.6.9 released ===================== py2exe is a Python distutils extension which converts Python scripts into executable Windows programs, able to run without requiring a Python...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.