Package SCons :: Package Script :: Module SConscript'
[hide private]
[frames] | no frames]

Source Code for Module SCons.Script.SConscript'

  1  """SCons.Script.SConscript 
  2   
  3  This module defines the Python API provided to SConscript and SConstruct 
  4  files. 
  5   
  6  """ 
  7   
  8  # 
  9  # Copyright (c) 2001 - 2019 The SCons Foundation 
 10  # 
 11  # Permission is hereby granted, free of charge, to any person obtaining 
 12  # a copy of this software and associated documentation files (the 
 13  # "Software"), to deal in the Software without restriction, including 
 14  # without limitation the rights to use, copy, modify, merge, publish, 
 15  # distribute, sublicense, and/or sell copies of the Software, and to 
 16  # permit persons to whom the Software is furnished to do so, subject to 
 17  # the following conditions: 
 18  # 
 19  # The above copyright notice and this permission notice shall be included 
 20  # in all copies or substantial portions of the Software. 
 21  # 
 22  # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 
 23  # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 
 24  # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
 25  # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 
 26  # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 
 27  # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 
 28  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
 29   
 30  __revision__ = "src/engine/SCons/Script/SConscript.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan" 
 31   
 32  import SCons 
 33  import SCons.Action 
 34  import SCons.Builder 
 35  import SCons.Defaults 
 36  import SCons.Environment 
 37  import SCons.Errors 
 38  import SCons.Node 
 39  import SCons.Node.Alias 
 40  import SCons.Node.FS 
 41  import SCons.Platform 
 42  import SCons.SConf 
 43  import SCons.Script.Main 
 44  import SCons.Tool 
 45  import SCons.Util 
 46   
 47  from . import Main 
 48   
 49  import collections 
 50  import os 
 51  import os.path 
 52  import re 
 53  import sys 
 54  import traceback 
 55  import time 
 56   
57 -class SConscriptReturn(Exception):
58 pass
59 60 launch_dir = os.path.abspath(os.curdir) 61 62 GlobalDict = None 63 64 # global exports set by Export(): 65 global_exports = {} 66 67 # chdir flag 68 sconscript_chdir = 1 69
70 -def get_calling_namespaces():
71 """Return the locals and globals for the function that called 72 into this module in the current call stack.""" 73 try: 1//0 74 except ZeroDivisionError: 75 # Don't start iterating with the current stack-frame to 76 # prevent creating reference cycles (f_back is safe). 77 frame = sys.exc_info()[2].tb_frame.f_back 78 79 # Find the first frame that *isn't* from this file. This means 80 # that we expect all of the SCons frames that implement an Export() 81 # or SConscript() call to be in this file, so that we can identify 82 # the first non-Script.SConscript frame as the user's local calling 83 # environment, and the locals and globals dictionaries from that 84 # frame as the calling namespaces. See the comment below preceding 85 # the DefaultEnvironmentCall block for even more explanation. 86 while frame.f_globals.get("__name__") == __name__: 87 frame = frame.f_back 88 89 return frame.f_locals, frame.f_globals
90 91
92 -def compute_exports(exports):
93 """Compute a dictionary of exports given one of the parameters 94 to the Export() function or the exports argument to SConscript().""" 95 96 loc, glob = get_calling_namespaces() 97 98 retval = {} 99 try: 100 for export in exports: 101 if SCons.Util.is_Dict(export): 102 retval.update(export) 103 else: 104 try: 105 retval[export] = loc[export] 106 except KeyError: 107 retval[export] = glob[export] 108 except KeyError as x: 109 raise SCons.Errors.UserError("Export of non-existent variable '%s'"%x) 110 111 return retval
112
113 -class Frame(object):
114 """A frame on the SConstruct/SConscript call stack"""
115 - def __init__(self, fs, exports, sconscript):
116 self.globals = BuildDefaultGlobals() 117 self.retval = None 118 self.prev_dir = fs.getcwd() 119 self.exports = compute_exports(exports) # exports from the calling SConscript 120 # make sure the sconscript attr is a Node. 121 if isinstance(sconscript, SCons.Node.Node): 122 self.sconscript = sconscript 123 elif sconscript == '-': 124 self.sconscript = None 125 else: 126 self.sconscript = fs.File(str(sconscript))
127 128 # the SConstruct/SConscript call stack: 129 call_stack = [] 130 131 # For documentation on the methods in this file, see the scons man-page 132
133 -def Return(*vars, **kw):
134 retval = [] 135 try: 136 fvars = SCons.Util.flatten(vars) 137 for var in fvars: 138 for v in var.split(): 139 retval.append(call_stack[-1].globals[v]) 140 except KeyError as x: 141 raise SCons.Errors.UserError("Return of non-existent variable '%s'"%x) 142 143 if len(retval) == 1: 144 call_stack[-1].retval = retval[0] 145 else: 146 call_stack[-1].retval = tuple(retval) 147 148 stop = kw.get('stop', True) 149 150 if stop: 151 raise SConscriptReturn
152 153 154 stack_bottom = '% Stack boTTom %' # hard to define a variable w/this name :) 155
156 -def handle_missing_SConscript(f, must_exist=None):
157 """Take appropriate action on missing file in SConscript() call. 158 159 Print a warning or raise an exception on missing file. 160 On first warning, print a deprecation message. 161 162 Args: 163 f (str): path of missing configuration file 164 must_exist (bool): raise exception if file does not exist 165 166 Raises: 167 UserError if 'must_exist' is True or if global 168 SCons.Script._no_missing_sconscript is True. 169 """ 170 171 if must_exist or (SCons.Script._no_missing_sconscript and must_exist is not False): 172 msg = "Fatal: missing SConscript '%s'" % f.get_internal_path() 173 raise SCons.Errors.UserError(msg) 174 175 if SCons.Script._warn_missing_sconscript_deprecated: 176 msg = "Calling missing SConscript without error is deprecated.\n" + \ 177 "Transition by adding must_exist=0 to SConscript calls.\n" + \ 178 "Missing SConscript '%s'" % f.get_internal_path() 179 SCons.Warnings.warn(SCons.Warnings.MissingSConscriptWarning, msg) 180 SCons.Script._warn_missing_sconscript_deprecated = False 181 else: 182 msg = "Ignoring missing SConscript '%s'" % f.get_internal_path() 183 SCons.Warnings.warn(SCons.Warnings.MissingSConscriptWarning, msg)
184
185 -def _SConscript(fs, *files, **kw):
186 top = fs.Top 187 sd = fs.SConstruct_dir.rdir() 188 exports = kw.get('exports', []) 189 190 # evaluate each SConscript file 191 results = [] 192 for fn in files: 193 call_stack.append(Frame(fs, exports, fn)) 194 old_sys_path = sys.path 195 try: 196 SCons.Script.sconscript_reading = SCons.Script.sconscript_reading + 1 197 if fn == "-": 198 exec(sys.stdin.read(), call_stack[-1].globals) 199 else: 200 if isinstance(fn, SCons.Node.Node): 201 f = fn 202 else: 203 f = fs.File(str(fn)) 204 _file_ = None 205 206 # Change directory to the top of the source 207 # tree to make sure the os's cwd and the cwd of 208 # fs match so we can open the SConscript. 209 fs.chdir(top, change_os_dir=1) 210 if f.rexists(): 211 actual = f.rfile() 212 _file_ = open(actual.get_abspath(), "rb") 213 elif f.srcnode().rexists(): 214 actual = f.srcnode().rfile() 215 _file_ = open(actual.get_abspath(), "rb") 216 elif f.has_src_builder(): 217 # The SConscript file apparently exists in a source 218 # code management system. Build it, but then clear 219 # the builder so that it doesn't get built *again* 220 # during the actual build phase. 221 f.build() 222 f.built() 223 f.builder_set(None) 224 if f.exists(): 225 _file_ = open(f.get_abspath(), "rb") 226 if _file_: 227 # Chdir to the SConscript directory. Use a path 228 # name relative to the SConstruct file so that if 229 # we're using the -f option, we're essentially 230 # creating a parallel SConscript directory structure 231 # in our local directory tree. 232 # 233 # XXX This is broken for multiple-repository cases 234 # where the SConstruct and SConscript files might be 235 # in different Repositories. For now, cross that 236 # bridge when someone comes to it. 237 try: 238 src_dir = kw['src_dir'] 239 except KeyError: 240 ldir = fs.Dir(f.dir.get_path(sd)) 241 else: 242 ldir = fs.Dir(src_dir) 243 if not ldir.is_under(f.dir): 244 # They specified a source directory, but 245 # it's above the SConscript directory. 246 # Do the sensible thing and just use the 247 # SConcript directory. 248 ldir = fs.Dir(f.dir.get_path(sd)) 249 try: 250 fs.chdir(ldir, change_os_dir=sconscript_chdir) 251 except OSError: 252 # There was no local directory, so we should be 253 # able to chdir to the Repository directory. 254 # Note that we do this directly, not through 255 # fs.chdir(), because we still need to 256 # interpret the stuff within the SConscript file 257 # relative to where we are logically. 258 fs.chdir(ldir, change_os_dir=0) 259 os.chdir(actual.dir.get_abspath()) 260 261 # Append the SConscript directory to the beginning 262 # of sys.path so Python modules in the SConscript 263 # directory can be easily imported. 264 sys.path = [ f.dir.get_abspath() ] + sys.path 265 266 # This is the magic line that actually reads up 267 # and executes the stuff in the SConscript file. 268 # The locals for this frame contain the special 269 # bottom-of-the-stack marker so that any 270 # exceptions that occur when processing this 271 # SConscript can base the printed frames at this 272 # level and not show SCons internals as well. 273 call_stack[-1].globals.update({stack_bottom:1}) 274 old_file = call_stack[-1].globals.get('__file__') 275 try: 276 del call_stack[-1].globals['__file__'] 277 except KeyError: 278 pass 279 try: 280 try: 281 if Main.print_time: 282 time1 = time.time() 283 scriptdata = _file_.read() 284 scriptname = _file_.name 285 _file_.close() 286 exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals) 287 except SConscriptReturn: 288 pass 289 finally: 290 if Main.print_time: 291 time2 = time.time() 292 print('SConscript:%s took %0.3f ms' % (f.get_abspath(), (time2 - time1) * 1000.0)) 293 294 if old_file is not None: 295 call_stack[-1].globals.update({__file__:old_file}) 296 else: 297 handle_missing_SConscript(f, kw.get('must_exist', None)) 298 299 finally: 300 SCons.Script.sconscript_reading = SCons.Script.sconscript_reading - 1 301 sys.path = old_sys_path 302 frame = call_stack.pop() 303 try: 304 fs.chdir(frame.prev_dir, change_os_dir=sconscript_chdir) 305 except OSError: 306 # There was no local directory, so chdir to the 307 # Repository directory. Like above, we do this 308 # directly. 309 fs.chdir(frame.prev_dir, change_os_dir=0) 310 rdir = frame.prev_dir.rdir() 311 rdir._create() # Make sure there's a directory there. 312 try: 313 os.chdir(rdir.get_abspath()) 314 except OSError as e: 315 # We still couldn't chdir there, so raise the error, 316 # but only if actions are being executed. 317 # 318 # If the -n option was used, the directory would *not* 319 # have been created and we should just carry on and 320 # let things muddle through. This isn't guaranteed 321 # to work if the SConscript files are reading things 322 # from disk (for example), but it should work well 323 # enough for most configurations. 324 if SCons.Action.execute_actions: 325 raise e 326 327 results.append(frame.retval) 328 329 # if we only have one script, don't return a tuple 330 if len(results) == 1: 331 return results[0] 332 else: 333 return tuple(results)
334
335 -def SConscript_exception(file=sys.stderr):
336 """Print an exception stack trace just for the SConscript file(s). 337 This will show users who have Python errors where the problem is, 338 without cluttering the output with all of the internal calls leading 339 up to where we exec the SConscript.""" 340 exc_type, exc_value, exc_tb = sys.exc_info() 341 tb = exc_tb 342 while tb and stack_bottom not in tb.tb_frame.f_locals: 343 tb = tb.tb_next 344 if not tb: 345 # We did not find our exec statement, so this was actually a bug 346 # in SCons itself. Show the whole stack. 347 tb = exc_tb 348 stack = traceback.extract_tb(tb) 349 try: 350 type = exc_type.__name__ 351 except AttributeError: 352 type = str(exc_type) 353 if type[:11] == "exceptions.": 354 type = type[11:] 355 file.write('%s: %s:\n' % (type, exc_value)) 356 for fname, line, func, text in stack: 357 file.write(' File "%s", line %d:\n' % (fname, line)) 358 file.write(' %s\n' % text)
359
360 -def annotate(node):
361 """Annotate a node with the stack frame describing the 362 SConscript file and line number that created it.""" 363 tb = sys.exc_info()[2] 364 while tb and stack_bottom not in tb.tb_frame.f_locals: 365 tb = tb.tb_next 366 if not tb: 367 # We did not find any exec of an SConscript file: what?! 368 raise SCons.Errors.InternalError("could not find SConscript stack frame") 369 node.creator = traceback.extract_stack(tb)[0]
370 371 # The following line would cause each Node to be annotated using the 372 # above function. Unfortunately, this is a *huge* performance hit, so 373 # leave this disabled until we find a more efficient mechanism. 374 #SCons.Node.Annotate = annotate 375
376 -class SConsEnvironment(SCons.Environment.Base):
377 """An Environment subclass that contains all of the methods that 378 are particular to the wrapper SCons interface and which aren't 379 (or shouldn't be) part of the build engine itself. 380 381 Note that not all of the methods of this class have corresponding 382 global functions, there are some private methods. 383 """ 384 385 # 386 # Private methods of an SConsEnvironment. 387 #
388 - def _exceeds_version(self, major, minor, v_major, v_minor):
389 """Return 1 if 'major' and 'minor' are greater than the version 390 in 'v_major' and 'v_minor', and 0 otherwise.""" 391 return (major > v_major or (major == v_major and minor > v_minor))
392
393 - def _get_major_minor_revision(self, version_string):
394 """Split a version string into major, minor and (optionally) 395 revision parts. 396 397 This is complicated by the fact that a version string can be 398 something like 3.2b1.""" 399 version = version_string.split(' ')[0].split('.') 400 v_major = int(version[0]) 401 v_minor = int(re.match(r'\d+', version[1]).group()) 402 if len(version) >= 3: 403 v_revision = int(re.match(r'\d+', version[2]).group()) 404 else: 405 v_revision = 0 406 return v_major, v_minor, v_revision
407
408 - def _get_SConscript_filenames(self, ls, kw):
409 """ 410 Convert the parameters passed to SConscript() calls into a list 411 of files and export variables. If the parameters are invalid, 412 throws SCons.Errors.UserError. Returns a tuple (l, e) where l 413 is a list of SConscript filenames and e is a list of exports. 414 """ 415 exports = [] 416 417 if len(ls) == 0: 418 try: 419 dirs = kw["dirs"] 420 except KeyError: 421 raise SCons.Errors.UserError("Invalid SConscript usage - no parameters") 422 423 if not SCons.Util.is_List(dirs): 424 dirs = [ dirs ] 425 dirs = list(map(str, dirs)) 426 427 name = kw.get('name', 'SConscript') 428 429 files = [os.path.join(n, name) for n in dirs] 430 431 elif len(ls) == 1: 432 433 files = ls[0] 434 435 elif len(ls) == 2: 436 437 files = ls[0] 438 exports = self.Split(ls[1]) 439 440 else: 441 442 raise SCons.Errors.UserError("Invalid SConscript() usage - too many arguments") 443 444 if not SCons.Util.is_List(files): 445 files = [ files ] 446 447 if kw.get('exports'): 448 exports.extend(self.Split(kw['exports'])) 449 450 variant_dir = kw.get('variant_dir') or kw.get('build_dir') 451 if variant_dir: 452 if len(files) != 1: 453 raise SCons.Errors.UserError("Invalid SConscript() usage - can only specify one SConscript with a variant_dir") 454 duplicate = kw.get('duplicate', 1) 455 src_dir = kw.get('src_dir') 456 if not src_dir: 457 src_dir, fname = os.path.split(str(files[0])) 458 files = [os.path.join(str(variant_dir), fname)] 459 else: 460 if not isinstance(src_dir, SCons.Node.Node): 461 src_dir = self.fs.Dir(src_dir) 462 fn = files[0] 463 if not isinstance(fn, SCons.Node.Node): 464 fn = self.fs.File(fn) 465 if fn.is_under(src_dir): 466 # Get path relative to the source directory. 467 fname = fn.get_path(src_dir) 468 files = [os.path.join(str(variant_dir), fname)] 469 else: 470 files = [fn.get_abspath()] 471 kw['src_dir'] = variant_dir 472 self.fs.VariantDir(variant_dir, src_dir, duplicate) 473 474 return (files, exports)
475 476 # 477 # Public methods of an SConsEnvironment. These get 478 # entry points in the global namespace so they can be called 479 # as global functions. 480 # 481
482 - def Configure(self, *args, **kw):
483 if not SCons.Script.sconscript_reading: 484 raise SCons.Errors.UserError("Calling Configure from Builders is not supported.") 485 kw['_depth'] = kw.get('_depth', 0) + 1 486 return SCons.Environment.Base.Configure(self, *args, **kw)
487
488 - def Default(self, *targets):
489 SCons.Script._Set_Default_Targets(self, targets)
490
491 - def EnsureSConsVersion(self, major, minor, revision=0):
492 """Exit abnormally if the SCons version is not late enough.""" 493 # split string to avoid replacement during build process 494 if SCons.__version__ == '__' + 'VERSION__': 495 SCons.Warnings.warn(SCons.Warnings.DevelopmentVersionWarning, 496 "EnsureSConsVersion is ignored for development version") 497 return 498 scons_ver = self._get_major_minor_revision(SCons.__version__) 499 if scons_ver < (major, minor, revision): 500 if revision: 501 scons_ver_string = '%d.%d.%d' % (major, minor, revision) 502 else: 503 scons_ver_string = '%d.%d' % (major, minor) 504 print("SCons %s or greater required, but you have SCons %s" % \ 505 (scons_ver_string, SCons.__version__)) 506 sys.exit(2)
507
508 - def EnsurePythonVersion(self, major, minor):
509 """Exit abnormally if the Python version is not late enough.""" 510 if sys.version_info < (major, minor): 511 v = sys.version.split()[0] 512 print("Python %d.%d or greater required, but you have Python %s" %(major,minor,v)) 513 sys.exit(2)
514
515 - def Exit(self, value=0):
516 sys.exit(value)
517
518 - def Export(self, *vars, **kw):
519 for var in vars: 520 global_exports.update(compute_exports(self.Split(var))) 521 global_exports.update(kw)
522
523 - def GetLaunchDir(self):
524 global launch_dir 525 return launch_dir
526
527 - def GetOption(self, name):
528 name = self.subst(name) 529 return SCons.Script.Main.GetOption(name)
530
531 - def Help(self, text, append=False):
532 text = self.subst(text, raw=1) 533 SCons.Script.HelpFunction(text, append=append)
534
535 - def Import(self, *vars):
536 try: 537 frame = call_stack[-1] 538 globals = frame.globals 539 exports = frame.exports 540 for var in vars: 541 var = self.Split(var) 542 for v in var: 543 if v == '*': 544 globals.update(global_exports) 545 globals.update(exports) 546 else: 547 if v in exports: 548 globals[v] = exports[v] 549 else: 550 globals[v] = global_exports[v] 551 except KeyError as x: 552 raise SCons.Errors.UserError("Import of non-existent variable '%s'"%x)
553
554 - def SConscript(self, *ls, **kw):
555 """Execute SCons configuration files. 556 557 Parameters: 558 *ls (str or list): configuration file(s) to execute. 559 560 Keyword arguments: 561 dirs (list): execute SConscript in each listed directory. 562 name (str): execute script 'name' (used only with 'dirs'). 563 exports (list or dict): locally export variables the 564 called script(s) can import. 565 variant_dir (str): mirror sources needed for the build in 566 a variant directory to allow building in it. 567 duplicate (bool): physically duplicate sources instead of just 568 adjusting paths of derived files (used only with 'variant_dir') 569 (default is True). 570 must_exist (bool): fail if a requested script is missing 571 (default is False, default is deprecated). 572 573 Returns: 574 list of variables returned by the called script 575 576 Raises: 577 UserError: a script is not found and such exceptions are enabled. 578 """ 579 580 if 'build_dir' in kw: 581 msg = """The build_dir keyword has been deprecated; use the variant_dir keyword instead.""" 582 SCons.Warnings.warn(SCons.Warnings.DeprecatedBuildDirWarning, msg) 583 def subst_element(x, subst=self.subst): 584 if SCons.Util.is_List(x): 585 x = list(map(subst, x)) 586 else: 587 x = subst(x) 588 return x
589 ls = list(map(subst_element, ls)) 590 subst_kw = {} 591 for key, val in kw.items(): 592 if SCons.Util.is_String(val): 593 val = self.subst(val) 594 elif SCons.Util.is_List(val): 595 result = [] 596 for v in val: 597 if SCons.Util.is_String(v): 598 v = self.subst(v) 599 result.append(v) 600 val = result 601 subst_kw[key] = val 602 603 files, exports = self._get_SConscript_filenames(ls, subst_kw) 604 subst_kw['exports'] = exports 605 return _SConscript(self.fs, *files, **subst_kw)
606
607 - def SConscriptChdir(self, flag):
608 global sconscript_chdir 609 sconscript_chdir = flag
610
611 - def SetOption(self, name, value):
612 name = self.subst(name) 613 SCons.Script.Main.SetOption(name, value)
614 615 # 616 # 617 # 618 SCons.Environment.Environment = SConsEnvironment 619
620 -def Configure(*args, **kw):
621 if not SCons.Script.sconscript_reading: 622 raise SCons.Errors.UserError("Calling Configure from Builders is not supported.") 623 kw['_depth'] = 1 624 return SCons.SConf.SConf(*args, **kw)
625 626 # It's very important that the DefaultEnvironmentCall() class stay in this 627 # file, with the get_calling_namespaces() function, the compute_exports() 628 # function, the Frame class and the SConsEnvironment.Export() method. 629 # These things make up the calling stack leading up to the actual global 630 # Export() or SConscript() call that the user issued. We want to allow 631 # users to export local variables that they define, like so: 632 # 633 # def func(): 634 # x = 1 635 # Export('x') 636 # 637 # To support this, the get_calling_namespaces() function assumes that 638 # the *first* stack frame that's not from this file is the local frame 639 # for the Export() or SConscript() call. 640 641 _DefaultEnvironmentProxy = None 642
643 -def get_DefaultEnvironmentProxy():
644 global _DefaultEnvironmentProxy 645 if not _DefaultEnvironmentProxy: 646 default_env = SCons.Defaults.DefaultEnvironment() 647 _DefaultEnvironmentProxy = SCons.Environment.NoSubstitutionProxy(default_env) 648 return _DefaultEnvironmentProxy
649
650 -class DefaultEnvironmentCall(object):
651 """A class that implements "global function" calls of 652 Environment methods by fetching the specified method from the 653 DefaultEnvironment's class. Note that this uses an intermediate 654 proxy class instead of calling the DefaultEnvironment method 655 directly so that the proxy can override the subst() method and 656 thereby prevent expansion of construction variables (since from 657 the user's point of view this was called as a global function, 658 with no associated construction environment)."""
659 - def __init__(self, method_name, subst=0):
660 self.method_name = method_name 661 if subst: 662 self.factory = SCons.Defaults.DefaultEnvironment 663 else: 664 self.factory = get_DefaultEnvironmentProxy
665 - def __call__(self, *args, **kw):
666 env = self.factory() 667 method = getattr(env, self.method_name) 668 return method(*args, **kw)
669 670
671 -def BuildDefaultGlobals():
672 """ 673 Create a dictionary containing all the default globals for 674 SConstruct and SConscript files. 675 """ 676 677 global GlobalDict 678 if GlobalDict is None: 679 GlobalDict = {} 680 681 import SCons.Script 682 d = SCons.Script.__dict__ 683 def not_a_module(m, d=d, mtype=type(SCons.Script)): 684 return not isinstance(d[m], mtype)
685 for m in filter(not_a_module, dir(SCons.Script)): 686 GlobalDict[m] = d[m] 687 688 return GlobalDict.copy() 689 690 # Local Variables: 691 # tab-width:4 692 # indent-tabs-mode:nil 693 # End: 694 # vim: set expandtab tabstop=4 shiftwidth=4: 695