Using Wing with scons

Index of All Documentation » How-Tos » How-Tos for Other Frameworks and Tools »

Wing is a Python IDE that can be used to develop, test, and debug Python code written for scons, an open source software construction or build control framework that uses Python. Two versions of Wing are appropriate for use with this document: Wing Pro is the full-featured Python IDE for professional programmers, and Wing Personal is a free alternative with reduced feature set.

If you do not already have Wing installed, download it now.

This document describes how to configure Wing for scons. To get started using Wing as your Python IDE, please refer to the tutorial in Wing's Help menu or read the 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/ (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)
    exec _file_ in call_stack[-1].globals
    if old_file is not None:

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, you will need to use wingdbstub to initiate debugging, as described in Debugging Externally Launched Code.

Related Documents

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