[Scons-users] Using Command with TryBuild

Carnë Draug carandraug+dev at gmail.com
Tue Feb 19 20:54:03 EST 2013


On 15 February 2013 16:53, Dirk Bächle <tshortik at gmx.de> wrote:

> On 15.02.2013 08:37, Carnë Draug wrote:

>>

>> I'm unable to use the Command builder with TryBuild. I get the following

>> error:

>>

>> AttributeError: 'NodeList' object has no attribute 'builder':

>> <snip>

>> File "/usr/lib/scons/SCons/SConf.py", line 799:

>> return self.sconf.TryBuild(*args, **kw)

>> File "/usr/lib/scons/SCons/SConf.py", line 546:

>> pref = self.env.subst( builder.builder.prefix )

>>

>> I'm using this has to check for the availability of a perl module

>>

>> context.TryBuild (context.env.Command(target = [], source = [], action

>> = "perl -M%s -e 1" % module))

>

>

> please don't use TryBuild or TryAction for these kind of checks. They are

> highly specialised methods, usually working together with the Object() or

> Program() Builders. In your case it makes sense to do the check completely

> on your own. Please, find a first simple version attached, based on

> subprocess. I hope you can put it to good use...


Hi Dirk

thank you very much and apologies for the very late reply.

I'm still learning the ropes with SCons and thought I should try to
use SCons methods as much as possible. I took your sample code and
just replaced Popen() with call(). It works fine now. For future
reference, here's the test function I'm using for perl modules

def CheckPerlModule(context, module_name):
context.Message("Checking for perl module %s..." % module_name)
is_ok = True
if (subprocess.call(["perl", "-M%s" % module_name, "-e 1"],
stderr = open(os.devnull, "wb"))):
is_ok = False
context.Result(is_ok)
return is_ok

Again, thank you,
Carnë


More information about the Scons-users mailing list