Skip to content

CheckLib fails if PRINT_CMD_LINE_FUNC used #2724

Description

@bdbaddog

This issue was originally created at: 2010-12-22 05:19:21.
This issue was reported by: reanimator.

reanimator said at 2010-12-22 05:19:21

CheckLib() fails if PRINT_CMD_LINE_FUNC set in environment and .sconsign.dblite removed:

$ rm .sconsign.dblite ; scons -f sconstruct_test
scons: Reading SConscript files ...
Checking for C library magic... no
libmagic.a required for test

The issue may be reproduce with 2.1.0-alpha, 2.0.1, 1.3.1;
Both on cygwin and Linux (sqlite-3.7.2, mysql-python-1.2.3).

The failure root cause is exception in SCons/Job.py:

scons: Configure: Checking for C library magic...
scons: Configure: Caught exception while building ".sconf_temp/conftest_0.c":
 
Traceback (most recent call last):
  File "/usr/lib/scons-1.3.1/SCons/Job.py", line 199, in start
    task.execute()
  File "/usr/lib/scons-1.3.1/SCons/SConf.py", line 358, in execute
    raise e
TypeError: cannot concatenate 'str' and 'list' objects
scons: Configure: no

Here is the simplest sconscript to repoduce the issue:

import sys
import os

def print_cmd_line(s, target, source, env):
    sys.stdout.write(os.linesep + source + os.linesep)
    return
 
# fails if PRINT_CMD_LINE_FUNC given
env = Environment(PRINT_CMD_LINE_FUNC=print_cmd_line)
 
# works if no PRINT_CMD_LINE_FUNC specified
# env = Environment()
 
env['ENV']['PATH'] = os.environ['PATH']
env['LIBPATH'] = ['.']
 
LibraryName         = 'magic'
LibraryFileName     = 'libmagic.a'
ExecName            = 'test'
 
Conf = Configure(env)
 
if not Conf.CheckLib(LibraryName):
    sys.stderr.write(LibraryFileName + ' required for ' + ExecName + os.linesep)
    env.Exit(1)
 
env = Conf.Finish()
 
ExecObj = env.Program(ExecName, ['test.c'], LIBS=[LibraryName], LIBPATH=['.'])

reanimator said at 2010-12-22 05:24:21

Here is the config.log for SCons-2.0.1:

scons: Configure: Caught exception while building ".sconf_temp/conftest_0.c":

Traceback (most recent call last):
 File "/usr/lib/scons-2.0.1/SCons/Job.py", line 201, in start
   task.execute()
 File "/usr/lib/scons-2.0.1/SCons/SConf.py", line 352, in execute
   raise e
TypeError: can't write str to text stream
scons: Configure: no

reanimator said at 2010-12-22 05:25:47

if I change the print_cmd_line
from

sys.stdout.write(os.linesep + source + os.linesep)

to

sys.stdout.write(os.linesep + str(source) + os.linesep)

Then it works scons-1.3.1 on cygwin, but not works with scons-2.0.1 on Linux.

dirkbaechle said at 2010-12-23 07:21:27

Hi Alexander,

I had a first short look at your problem...can you please try

 sys.stdout.write(os.linesep + unicode(source[0]) + os.linesep)

instead of your

 sys.stdout.write(os.linesep + str(source) + os.linesep)

? Please also refer to

https://stackoverflow.com/questions/4512982/python-typeerror-cant-write-str-to-text-stream

and see if this resolves your problem. Please give some feedback about the results, such that we can decide whether to debug the issue further.

Best regards,

Dirk

P.S.: On my machine (Linux, 64bit, SuSE 10.1) I don't get the error, when running the latest SCons version from the trunk. So, it might be worthwhile to give the HEAD revision a spin...

reanimator said at 2010-12-24 01:50:12

unicode(source[0]) works under Linux with scons-2.0.1;

P.S.
I have not tried scons from trunk because of build failure
(error: /usr/lib/python2.6/distutils/command/wininst-6.0.exe: No such file or directory).
Seems to be because of python-2.3 required?!

bdbaddog said at 2010-12-24 09:14:07

re: build issue
python bootstrap.py build/scons-local and then use that.

The package doesn't build on python 2.6 or newer as yet.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions