[Scons-users] [Scons-dev] howto debug configure
Paweł Tomulik
ptomulik at meil.pw.edu.pl
Thu Apr 3 14:57:25 EDT 2014
William,
Neal is the original author of this thread. I just replied with a
possible solution. The PR report I mentioned contains an example. Let me
just paste it here:
<code>
# SConstruct
#
# The CheckHello should return 'yes' if everything works fine. Othervise it
# returns 'failed'.
#
def hello(target, source, env):
import traceback
try:
print 'hello!\n' # this breaks the script
with open(env.subst('$TARGET', target = target),'w') as f:
f.write('yes')
except:
# write to file, as stdout/stderr is broken
traceback.print_exc(file=open('traceback','w'))
return 0
def CheckHello(context):
import sys
context.Display('Checking whether hello works... ')
stat,out = context.TryAction(hello,'','.in')
if stat and out:
context.Result(out)
else:
context.Result('failed')
return out
env = Environment()
cfg = Configure(env)
cfg.AddTest('CheckHello', CheckHello)
cfg.CheckHello()
env = cfg.Finish()
</code>
Few words of explanation:
The above code raises "TypeError: unicode argument expected, got 'str'"
in the line "print ....". Normally such an exception is eaten by SConf
machinery and it's quite hard to debug. Above I just write its backtrace
to 'traceback' file, as stdout/stderr is captured by SConf.Streamer
which is broken. The backtrace points to line 183 of SCons/SConf.py:
Traceback (most recent call last):
File "SConstruct", line 9, in hello
print 'hello!\n' # this breaks the script
File "/usr/lib/scons/SCons/SConf.py", line 183, in write
self.s.write(str)
Here the "self.s" object is an instance of io.StringIO. On python 2.x
io.StringIO accepts only unicode, and doesn't accept str - and this is
main reason why this code fails.
W dniu 03.04.2014 19:40, William Deegan pisze:
> Pawel,
>
> Likely you’re better off bringing such questions to the users mailing
> list. The devel mailing list is meant to discuss the internal
> development of SCons. I’m cc’ing that list. I believe there is a
> config.log generated when you run the configure context.
>
> Also, can you create a small reproducible test case for this? That
> way we can try it out and see what’s going on.
>
>
> -Bill
>
> On April 3, 2014 at 2:13:01 AM, Paweł Tomulik
> (ptomulik at meil.pw.edu.pl) wrote:
>> W dniu 06.09.2013 19:47, Neal Becker pisze:
>>> I have a lot working, but not configure. I don't know how to
>>> debug it.
>>>
>>> even with --debug=stacktrace, the stack trace is not useful. I
>>> don't have any idea where this error is coming from:
>>>
>>> file ,line 92: Configure(confdir = .sconf_temp) scons: Configure:
>>> Checking for C header file unuran.h... .sconf_temp/conftest_0.c
>>> <- | |#include "unuran.h" | | scons: Configure: Caught exception
>>> while building ".sconf_temp/conftest_0.c":
>>>
>>> Traceback (most recent call last): File
>>> "/home/nbecker/scons-replaced-by-scons-
>>> p3/bootstrap/src/engine/SCons/Job.py", line 201, in start
>>> task.execute() File "/home/nbecker/scons-replaced-by-scons-
>>> p3/bootstrap/src/engine/SCons/SConf.py", line 352, in execute
>>> raise e TypeError: unicode argument expected, got 'str'
>>>
>>> _______________________________________________ Scons-dev mailing
>>> list Scons-dev at scons.org
>>> http://two.pairlist.net/mailman/listinfo/scons-dev
>>
>> Hi,
>>
>> I think, this is a bug in SCons. I've addressed it in BitBucket PR
>> 126: https://bitbucket.org/scons/scons/pull-request/126/
>>
>> Best Regards!
>>
>> -- Pawel Tomulik
>>
>> _______________________________________________ Scons-dev mailing
>> list Scons-dev at scons.org
>> http://two.pairlist.net/mailman/listinfo/scons-dev
>>
>
--
Pawel Tomulik
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://four.pairlist.net/pipermail/scons-users/attachments/20140403/bcab12a3/attachment.htm
More information about the Scons-users
mailing list