Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug SCons script

I have a SCons script that I need to debug. Somewhere down inside of everything that is happening, I have a problem and I need to find out where it is going bad.

I'd like to debug the SCons script, but I'm not sure how to get it set up. I have both PyCharm and Komodo IDEs, but I couldn't figure out how to make those work.

I've tried this:

scons --debug=pdb <args...>

but that just gets me inside of SCons; I need to be inside of the scripts that I've created that SCons runs.

Can someone show me how to set up PyCharm or Komodo to debug a SCons script? If that isn't possible, I'm open to other debugging options.

like image 939
jlconlin Avatar asked Apr 02 '14 17:04

jlconlin


2 Answers

In your SConstruct:

import pdb
pdb.set_trace()

And you'll drop into the debugger inside your SConstruct (or SConscript if that's what you're trying to debug).

like image 194
bdbaddog Avatar answered Oct 01 '22 08:10

bdbaddog


With PyCharm you can use remote debugging.

Find the remote debugger package in your PyCharm installation:

  • Python 2.x: pycharm-debug.egg
  • Python 3.x: pycharm-debug-py3k.egg

Install the egg using easy_install. It should be found in your Python deployment. On Windows look into the Scripts folder.

Follow the Remote Debugging HowTo.

Run the Python code you would like to debug in any way you want, it will connect to PyCharm's debug server and stop in the script.

Screenshot of debugging Godot's SConstruct file: enter image description here

Scons was executed from a Visual Studio command line in order to receive the right environment variables for the build (not from PyCharm).

UPDATE: A simpler solution is to add a run configuration directly for scons.py itself. You can issue a SET command in an Visual Studio command prompt, copy all environment variables printed and paste into the Environment setting of the run configuration inside PyCharm. With that configuration you can debug the whole scons based build, including your SConstruct file.

like image 43
fviktor Avatar answered Oct 01 '22 07:10

fviktor