Вопрос

I'm trying to debug a SConstruct file that's failing deep deep into some obscure function, and I want to step through the code. This is what I tried to do, and failed:

$ python -m pdb `which scons.py`
> c:\python27\scripts\scons.py(26)<module>()
-> __revision__ = "src/script/scons.py 5357 2011/09/09 21:31:03 bdeegan"
(Pdb) b SConstruct:10
***  'SConstruct' not found from sys.path
(Pdb) import sys, os
(Pdb) sys.path.append(os.getcwd())
(Pdb) b SConstruct:10
***  'SConstruct' not found from sys.path
(Pdb)

If I rename SConstruct to SConstruct.py, it succeeds to set a breakpoint, but of course it doesn't work, because "scons" loads SConstruct, not SConstruct.py. Any way to force python to put a breakpoint there?

I'm running this from a msys bash console on a Win7 system. Python version:

$ python
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Это было полезно?

Решение

There are some tips on the Debugging SCons wiki page. Specifically:

scons --debug=pdb <args...>
# from the wiki example: you can set a breakpoint on a file relative to sys.path
(Pdb) b SCons/Tool/msvc.py:158 
# you can set a breakpoint in the SConstruct file with the full path
(Pdb) b /Users/me/code/project/SConstruct:10
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top