Home » Support » Index of All Documentation » How-Tos » How-Tos for Other Libraries »

Wing IDE is an integrated development environment that can be used to edit, test, and debug Python code that is written for scons, an open source software construction or build control framework that uses Python. Wing provides auto-completion, call tips, a powerful debugger, and many other features that help you write, navigate, and understand Python code.

For more information on Wing IDE see the product overview. If you do not already have Wing IDE installed, download a free trial now.

To get started using Wing, refer to the tutorial in the Help menu in Wing and/or the Wing IDE Quickstart Guide.

Debugging scons

As of version 0.96.1 of scons, the way that scons executes build control scripts does not work properly with any Python debugger because the scripts are executed in an environment that effectively sets the wrong file name for the script. Wing will bring up the wrong file on exceptions and will fail to stop on breakpoints.

The solution for this is to patch scons by replacing the exec _file_ call with one that unsets the incorrect file name, so that Wing's debugger looks into the correctly set co_filename in the code objects instead.

The code to replace is in engine/SCons/Script/SConscript.py (around line 239 in scons version 0.96.1):

exec _file_ in stack[-1].globals

Here is the replacement code to use:

old_file = call_stack[-1].globals.pop('__file__', None)
try:
    exec _file_ in call_stack[-1].globals
finally:
    if old_file is not None:
        call_stack[-1].globals.update({__file__:old_file})

Once this is done, Wing should show the correct file on exceptions and stop on breakpoints set within the IDE.

Note that if you launch scons from the command line (likely the preferred method) rather than from within Wing IDE, you will need to use wingdbstub to initiate debugging, as described in Debugging Externally Launched Code.

Related Documents

Wing IDE provides many other options and tools. For more information:

« 5.3. Using Wing IDE with pygameTable of Contents5.5. Using Wing IDE with IDA Python »

Using Wing IDE with scons