Search code examples
pythoneclipsescons

Debug Sconscript file eclipse


I have python project that is already built based on Scons.

I am trying to use Eclipse IDE and Pydev to fix some bugs in the source code.

I have installed Eclispe Sconsolidator plugin.

My project is like below Project A all source codes including Sconscript file which defines all the tager, environmet etc.

Eclipse provide me with Add Scons nature to the project. Once added the Scons automatically picks up my Sconscript file and executes.

== Running SCons at 10/28/13 1:59 PM ==

Command line: /opt/gcdistro/app/scons/2.3.0/bin/scons -u --jobs=16

scons: Reading SConscript files.

I want to know how can I place breakpoints in some of the .py files that is a part of my project which Scons is executing.


Solution

  • After a bit of struggle I was able to find answer to my question. Since SCons is a python module by itself, it is possible to debug it in eclipse using PyDev. This is not the most optimal solution I wanted but was the closest.

    Step 1: I disabled the Eclipse SCons nature of the project.

    Step 2: Created a main file that will do the same function of SCons but instantiate the python object of the SCons main function.

    Step 3: Set the breakpoints in my script where wanted and it was able to execute it.

    import os
    import sys
    
    if __name__ == '__main__':
        sys.path.append('/gpfs02/gcdistro/app/scons/2.3.0/engine/')
        sys.path.append('/gpfs02/gcdistro/app/scons/2.3.0/bin/')
        sys.path.append('/gpfs02/gcdistro/app/scons/2.3.0/engine/SCons/')
        import SCons
        from SCons import Script
        Script.main()