Question

I'm a newbie to SCons and also using pydev. Can someone help me with instructions on how to debug scons scripts using Eclipse and pydev? Is it even possible considering the fact that SCons is a seperate app and not an extension to python?

Was it helpful?

Solution

I'm not an Eclipse expert, but since you didn't get any other answer...

If you make the SCons source a part of the Eclipse project, and run the whole command from within Eclipse it should work like any Eclipse debugging. SCons is written in Python, there is no reason it shouldn't be debuggable in Eclipse just like anything else.

OTHER TIPS

You are right. Since the SCons is python based, the SCons scripts are debuggable via EClipse PyDev. For this, you need to do the following in the debug configuration...

  • 1. Under the main tab, set the main module to the SCons file which will be available under the python/scripts directory if you have installed SCons. If you have not run the install of SCons you can point to this file under the SCons directory.
  • 2. Under the arguments tab, set the working directory to the root of your project.

    Now set the breakpoint either on SConstruct or SConcript and run in debug mode. That's all!! With this approach you can not only debug your product code but also the build scripts that builds your product :-) Happy Debugging!!!!

  • if you are using SCons for C/C++ development and Eclipse CDT check out http://sconsolidator.com (within the next weeks), we will release our SCons Eclipse plug-in for free public use shortly. It also contains an "interactive mode" that allows SCons builds to run more quickly (no startup time) and also to debug SCons in a console. However, the tip with using PyDev still applies (can be installed alongside with CDT in the same Eclipse instance.

    On MAC to debug scons through pydev follow Lennart's answer but with one simply addition.

    Using Finder (or terminal) browse to where scons is installed. You can find this with the "which" command.

    e.g. which scons -> /usr/local/bin/scons

    Make a copy of the scons file and call it scons.py.

    Now when you create the Debug Configuration in Eclipse use scons.py as the "Main Module".

    PS: To add a scons project to Eclipse I found it easier to use a "Linked Folder" pointing at /usr/local/bin/. i.e. Because I was getting a read-only error when trying to add the directory itself.

    I've since gain more experience with SCons / Python and I'd recommend using python's pdb module. To use it simply add the following code to your SCons/Python files.

    import pdb; pdb.set_trace()

    When the file is run from the command line a breakpoint will be hit at this line. I also moved away from Eclipse. A lightweight editor will be just as good for Python development. I use Sublime.

    As an addendum: on Windows, I had to copy the scons-installed files to reside under C:\Python27\Lib\site-packages\scons in order for this to work. Adding the original installed location, qualified with the version number, to the PYTHONPATH, did not work.

    Licensed under: CC-BY-SA with attribution
    Not affiliated with StackOverflow
    scroll top