SCons.Script package

Contents

SCons.Script package#

Submodules#

SCons.Script.Interactive module#

SCons interactive mode.

class SCons.Script.Interactive.SConsInteractiveCmd(**kw)[source]#

Bases: Cmd

build [TARGETS] Build the specified TARGETS and their dependencies. ‘b’ is a synonym. clean [TARGETS] Clean (remove) the specified TARGETS and their dependencies. ‘c’ is a synonym. exit Exit SCons interactive mode. help [COMMAND] Prints help for the specified COMMAND. ‘h’ and ‘?’ are synonyms. shell [COMMANDLINE] Execute COMMANDLINE in a subshell. ‘sh’ and ‘!’ are synonyms. version Prints SCons version information.

_do_one_help(arg) None[source]#
_doc_to_help(obj)[source]#
_strip_initial_spaces(s)[source]#
cmdloop(intro=None)#

Repeatedly issue a prompt, accept input, parse an initial prefix off the received input, and dispatch to action methods, passing them the remainder of the line as argument.

columnize(list, displaywidth=80)#

Display a list of strings as a compact set of columns.

Each column is only as wide as necessary. Columns are separated by two spaces (one was not legible enough).

complete(text, state)#

Return the next possible completion for ‘text’.

If a command has not been entered, then complete against command list. Otherwise try to call complete_<command> to get list of completions.

complete_help(*args)#
completedefault(*ignored)#

Method called to complete an input line when no command-specific complete_*() method is available.

By default, it returns an empty list.

completenames(text, *ignored)#
default(argv) None[source]#

Called on an input line when the command prefix is not recognized.

If this method is not overridden, it prints an error message and returns.

do_EOF(argv) None[source]#
do_build(argv) None[source]#

build [TARGETS] Build the specified TARGETS and their dependencies. ‘b’ is a synonym.

do_clean(argv)[source]#

clean [TARGETS] Clean (remove) the specified TARGETS and their dependencies. ‘c’ is a synonym.

do_exit(argv) None[source]#

exit Exit SCons interactive mode.

do_help(argv) None[source]#

help [COMMAND] Prints help for the specified COMMAND. ‘h’ and ‘?’ are synonyms.

do_shell(argv) None[source]#

shell [COMMANDLINE] Execute COMMANDLINE in a subshell. ‘sh’ and ‘!’ are synonyms.

do_version(argv) None[source]#

version Prints SCons version information.

doc_header = 'Documented commands (type help <topic>):'#
doc_leader = ''#
emptyline()#

Called when an empty line is entered in response to the prompt.

If this method is not overridden, it repeats the last nonempty command entered.

get_names()#
identchars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_'#
intro = None#
lastcmd = ''#
misc_header = 'Miscellaneous help topics:'#
nohelp = '*** No help on %s'#
onecmd(line)[source]#

Interpret the argument as though it had been typed in response to the prompt.

This may be overridden, but should not normally need to be; see the precmd() and postcmd() methods for useful execution hooks. The return value is a flag indicating whether interpretation of commands by the interpreter should stop.

parseline(line)#

Parse the line into a command name and a string containing the arguments. Returns a tuple containing (command, args, line). ‘command’ and ‘args’ may be None if the line couldn’t be parsed.

postcmd(stop, line)#

Hook method executed just after a command dispatch is finished.

postloop()#

Hook method executed once when the cmdloop() method is about to return.

precmd(line)#

Hook method executed just before the command line is interpreted, but after the input prompt is generated and issued.

preloop()#

Hook method executed once when the cmdloop() method is called.

print_topics(header, cmds, cmdlen, maxcol)#
prompt = '(Cmd) '#
ruler = '='#
synonyms = {'b': 'build', 'c': 'clean', 'h': 'help', 'scons': 'build', 'sh': 'shell'}#
undoc_header = 'Undocumented commands:'#
use_rawinput = 1#
SCons.Script.Interactive.interact(fs, parser, options, targets, target_top) None[source]#

SCons.Script.Main module#

The main() function used by the scons script.

Architecturally, this is the scons script, and will likely only be called from the external “scons” wrapper. Consequently, anything here should not be, or be considered, part of the build engine. If it’s something that we expect other software to want to use, it should go in some other module. If it’s specific to the “scons” script invocation, it goes here.

SCons.Script.Main.AddOption(*args, **kw)[source]#
class SCons.Script.Main.BuildTask(tm, targets, top, node)[source]#

Bases: OutOfDateTask

An SCons build task.

LOGGER = None#
_abc_impl = <_abc._abc_data object>#
_exception_raise()#

Raises a pending exception that was recorded while getting a Task ready for execution.

_no_exception_to_raise() None#
display(message) None[source]#

Hook to allow the calling interface to display a message.

This hook gets called as part of preparing a task for execution (that is, a Node to be built). As part of figuring out what Node should be built next, the actual target list may be altered, along with a message describing the alteration. The calling interface can subclass Task and provide a concrete implementation of this method to see those messages.

do_failed(status: int = 2) None[source]#
exc_clear() None#

Clears any recorded exception.

This also changes the “exception_raise” attribute to point to the appropriate do-nothing method.

exc_info()#

Returns info about a recorded exception.

exception_set(exception=None) None#

Records an exception to be raised at the appropriate time.

This also changes the “exception_raise” attribute to point to the method that will, in fact

execute() None[source]#

Called to execute the task.

This method is called from multiple threads in a parallel build, so only do thread safe stuff here. Do thread unsafe stuff in prepare(), executed() or failed().

executed()[source]#

Called when the task has been successfully executed and the Taskmaster instance wants to call the Node’s callback methods.

This may have been a do-nothing operation (to preserve build order), so we must check the node’s state before deciding whether it was “built”, in which case we call the appropriate Node method. In any event, we always call “visited()”, which will handle any post-visit actions that must take place regardless of whether or not the target was an actual built target or a source Node.

executed_with_callbacks() None#

Called when the task has been successfully executed and the Taskmaster instance wants to call the Node’s callback methods.

This may have been a do-nothing operation (to preserve build order), so we must check the node’s state before deciding whether it was “built”, in which case we call the appropriate Node method. In any event, we always call “visited()”, which will handle any post-visit actions that must take place regardless of whether or not the target was an actual built target or a source Node.

executed_without_callbacks() None#

Called when the task has been successfully executed and the Taskmaster instance doesn’t want to call the Node’s callback methods.

fail_continue() None#

Explicit continue-the-build failure.

This sets failure status on the target nodes and all of their dependent parent nodes.

Note: Although this function is normally invoked on nodes in the executing state, it might also be invoked on up-to-date nodes when using Configure().

fail_stop() None#

Explicit stop-the-build failure.

This sets failure status on the target nodes and all of their dependent parent nodes.

Note: Although this function is normally invoked on nodes in the executing state, it might also be invoked on up-to-date nodes when using Configure().

failed() None[source]#

Default action when a task fails: stop the build.

Note: Although this function is normally invoked on nodes in the executing state, it might also be invoked on up-to-date nodes when using Configure().

get_target()#

Fetch the target being built or updated by this task.

make_ready() None[source]#

Make a task ready for execution

make_ready_all() None#

Marks all targets in a task ready for execution.

This is used when the interface needs every target Node to be visited–the canonical example being the “scons -c” option.

make_ready_current()#

Marks all targets in a task ready for execution if any target is not current.

This is the default behavior for building only what’s necessary.

needs_execute() bool[source]#

Returns True (indicating this Task should be executed) if this Task’s target state indicates it needs executing, which has already been determined by an earlier up-to-date check.

postprocess() None[source]#

Post-processes a task after it’s been executed.

This examines all the targets just built (or not, we don’t care if the build was successful, or even if there was no build because everything was up-to-date) to see if they have any waiting parent Nodes, or Nodes waiting on a common side effect, that can be put back on the candidates list.

prepare()[source]#

Called just before the task is executed.

This is mainly intended to give the target Nodes a chance to unlink underlying files and make all necessary directories before the Action is actually called to build the targets.

trace_message(node, description: str = 'node') None#
class SCons.Script.Main.CleanTask(tm, targets, top, node)[source]#

Bases: AlwaysTask

An SCons clean task.

LOGGER = None#
_abc_impl = <_abc._abc_data object>#
_clean_targets(remove: bool = True) None[source]#
_exception_raise()#

Raises a pending exception that was recorded while getting a Task ready for execution.

_get_files_to_clean()[source]#
_no_exception_to_raise() None#
display(message) None#

Hook to allow the calling interface to display a message.

This hook gets called as part of preparing a task for execution (that is, a Node to be built). As part of figuring out what Node should be built next, the actual target list may be altered, along with a message describing the alteration. The calling interface can subclass Task and provide a concrete implementation of this method to see those messages.

exc_clear() None#

Clears any recorded exception.

This also changes the “exception_raise” attribute to point to the appropriate do-nothing method.

exc_info()#

Returns info about a recorded exception.

exception_set(exception=None) None#

Records an exception to be raised at the appropriate time.

This also changes the “exception_raise” attribute to point to the method that will, in fact

execute() None#

Called to execute the task.

This method is called from multiple threads in a parallel build, so only do thread safe stuff here. Do thread unsafe stuff in prepare(), executed() or failed().

executed() None#

Called when the task has been successfully executed and the Taskmaster instance doesn’t want to call the Node’s callback methods.

executed_with_callbacks() None#

Called when the task has been successfully executed and the Taskmaster instance wants to call the Node’s callback methods.

This may have been a do-nothing operation (to preserve build order), so we must check the node’s state before deciding whether it was “built”, in which case we call the appropriate Node method. In any event, we always call “visited()”, which will handle any post-visit actions that must take place regardless of whether or not the target was an actual built target or a source Node.

executed_without_callbacks() None#

Called when the task has been successfully executed and the Taskmaster instance doesn’t want to call the Node’s callback methods.

fail_continue() None#

Explicit continue-the-build failure.

This sets failure status on the target nodes and all of their dependent parent nodes.

Note: Although this function is normally invoked on nodes in the executing state, it might also be invoked on up-to-date nodes when using Configure().

fail_stop() None#

Explicit stop-the-build failure.

This sets failure status on the target nodes and all of their dependent parent nodes.

Note: Although this function is normally invoked on nodes in the executing state, it might also be invoked on up-to-date nodes when using Configure().

failed() None#

Default action when a task fails: stop the build.

Note: Although this function is normally invoked on nodes in the executing state, it might also be invoked on up-to-date nodes when using Configure().

fs_delete(path, pathstr, remove: bool = True)[source]#
get_target()#

Fetch the target being built or updated by this task.

make_ready() None#

Marks all targets in a task ready for execution.

This is used when the interface needs every target Node to be visited–the canonical example being the “scons -c” option.

make_ready_all() None#

Marks all targets in a task ready for execution.

This is used when the interface needs every target Node to be visited–the canonical example being the “scons -c” option.

make_ready_current()#

Marks all targets in a task ready for execution if any target is not current.

This is the default behavior for building only what’s necessary.

needs_execute() bool#

Always returns True (indicating this Task should always be executed).

Subclasses that need this behavior (as opposed to the default of only executing Nodes that are out of date w.r.t. their dependencies) can use this as follows:

class MyTaskSubclass(SCons.Taskmaster.Task):

needs_execute = SCons.Taskmaster.AlwaysTask.needs_execute

postprocess() None#

Post-processes a task after it’s been executed.

This examines all the targets just built (or not, we don’t care if the build was successful, or even if there was no build because everything was up-to-date) to see if they have any waiting parent Nodes, or Nodes waiting on a common side effect, that can be put back on the candidates list.

prepare() None[source]#

Called just before the task is executed.

This is mainly intended to give the target Nodes a chance to unlink underlying files and make all necessary directories before the Action is actually called to build the targets.

remove() None[source]#
show() None[source]#
trace_message(node, description: str = 'node') None#
SCons.Script.Main.DebugOptions(json=None)[source]#

API to allow specifying options to SCons debug logic Currently only json is supported which changes the json file written by –debug=json from the default

class SCons.Script.Main.FakeOptionParser[source]#

Bases: object

A do-nothing option parser, used for the initial OptionsParser value.

During normal SCons operation, the OptionsParser is created right away by the main() function. Certain test scripts however, can introspect on different Tool modules, the initialization of which can try to add a new, local option to an otherwise uninitialized OptionsParser object. This allows that introspection to happen without blowing up.

class FakeOptionValues[source]#

Bases: object

add_local_option(*args, **kw) None[source]#
values = <SCons.Script.Main.FakeOptionParser.FakeOptionValues object>#
SCons.Script.Main.GetBuildFailures()[source]#
SCons.Script.Main.GetOption(name)[source]#
SCons.Script.Main.PrintHelp(file=None, local_only: bool = False) None[source]#
SCons.Script.Main.Progress(*args, **kw) None[source]#
class SCons.Script.Main.Progressor(obj, interval: int = 1, file=None, overwrite: bool = False)[source]#

Bases: object

count = 0#
erase_previous() None[source]#
prev = ''#
replace_string(node) None[source]#
spinner(node) None[source]#
string(node) None[source]#
target_string = '$TARGET'#
write(s) None[source]#
class SCons.Script.Main.QuestionTask(tm, targets, top, node)[source]#

Bases: AlwaysTask

An SCons task for the -q (question) option.

LOGGER = None#
_abc_impl = <_abc._abc_data object>#
_exception_raise()#

Raises a pending exception that was recorded while getting a Task ready for execution.

_no_exception_to_raise() None#
display(message) None#

Hook to allow the calling interface to display a message.

This hook gets called as part of preparing a task for execution (that is, a Node to be built). As part of figuring out what Node should be built next, the actual target list may be altered, along with a message describing the alteration. The calling interface can subclass Task and provide a concrete implementation of this method to see those messages.

exc_clear() None#

Clears any recorded exception.

This also changes the “exception_raise” attribute to point to the appropriate do-nothing method.

exc_info()#

Returns info about a recorded exception.

exception_set(exception=None) None#

Records an exception to be raised at the appropriate time.

This also changes the “exception_raise” attribute to point to the method that will, in fact

execute() None[source]#

Called to execute the task.

This method is called from multiple threads in a parallel build, so only do thread safe stuff here. Do thread unsafe stuff in prepare(), executed() or failed().

executed() None[source]#

Called when the task has been successfully executed and the Taskmaster instance wants to call the Node’s callback methods.

This may have been a do-nothing operation (to preserve build order), so we must check the node’s state before deciding whether it was “built”, in which case we call the appropriate Node method. In any event, we always call “visited()”, which will handle any post-visit actions that must take place regardless of whether or not the target was an actual built target or a source Node.

executed_with_callbacks() None#

Called when the task has been successfully executed and the Taskmaster instance wants to call the Node’s callback methods.

This may have been a do-nothing operation (to preserve build order), so we must check the node’s state before deciding whether it was “built”, in which case we call the appropriate Node method. In any event, we always call “visited()”, which will handle any post-visit actions that must take place regardless of whether or not the target was an actual built target or a source Node.

executed_without_callbacks() None#

Called when the task has been successfully executed and the Taskmaster instance doesn’t want to call the Node’s callback methods.

fail_continue() None#

Explicit continue-the-build failure.

This sets failure status on the target nodes and all of their dependent parent nodes.

Note: Although this function is normally invoked on nodes in the executing state, it might also be invoked on up-to-date nodes when using Configure().

fail_stop() None#

Explicit stop-the-build failure.

This sets failure status on the target nodes and all of their dependent parent nodes.

Note: Although this function is normally invoked on nodes in the executing state, it might also be invoked on up-to-date nodes when using Configure().

failed() None#

Default action when a task fails: stop the build.

Note: Although this function is normally invoked on nodes in the executing state, it might also be invoked on up-to-date nodes when using Configure().

get_target()#

Fetch the target being built or updated by this task.

make_ready()#

Marks all targets in a task ready for execution if any target is not current.

This is the default behavior for building only what’s necessary.

make_ready_all() None#

Marks all targets in a task ready for execution.

This is used when the interface needs every target Node to be visited–the canonical example being the “scons -c” option.

make_ready_current()#

Marks all targets in a task ready for execution if any target is not current.

This is the default behavior for building only what’s necessary.

needs_execute() bool#

Always returns True (indicating this Task should always be executed).

Subclasses that need this behavior (as opposed to the default of only executing Nodes that are out of date w.r.t. their dependencies) can use this as follows:

class MyTaskSubclass(SCons.Taskmaster.Task):

needs_execute = SCons.Taskmaster.AlwaysTask.needs_execute

postprocess() None#

Post-processes a task after it’s been executed.

This examines all the targets just built (or not, we don’t care if the build was successful, or even if there was no build because everything was up-to-date) to see if they have any waiting parent Nodes, or Nodes waiting on a common side effect, that can be put back on the candidates list.

prepare() None[source]#

Called just before the task is executed.

This is mainly intended to give the target Nodes a chance to unlink underlying files and make all necessary directories before the Action is actually called to build the targets.

trace_message(node, description: str = 'node') None#
exception SCons.Script.Main.SConsPrintHelpException[source]#

Bases: Exception

add_note()#

Exception.add_note(note) – add a note to the exception

args#
with_traceback()#

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

SCons.Script.Main.SetOption(name, value)[source]#
class SCons.Script.Main.TreePrinter(derived: bool = False, prune: bool = False, status: bool = False, sLineDraw: bool = False)[source]#

Bases: object

display(t) None[source]#
get_all_children(node)[source]#
get_derived_children(node)[source]#
SCons.Script.Main.ValidateOptions(throw_exception: bool = False) None[source]#

Validate options passed to SCons on the command line.

Checks that all options given on the command line are known to this instance of SCons. Call after all of the cli options have been set up through AddOption() calls. For example, if you added an option --xyz and you call SCons with --xyy you can cause SCons to issue an error message and exit by calling this function.

Parameters:

throw_exception – if an invalid option is present on the command line, raises an exception if this optional parameter evaluates true; if false (the default), issue a message and exit with error status.

Raises:

SConsBadOptionError – If throw_exception is true and there are invalid options on the command line.

New in version 4.5.0.

SCons.Script.Main._SConstruct_exists(dirname: str, repositories: List[str], filelist: List[str]) str | None[source]#

Check that an SConstruct file exists in a directory.

Parameters:
  • dirname – the directory to search. If empty, look in cwd.

  • repositories – a list of repositories to search in addition to the project directory tree.

  • filelist – names of SConstruct file(s) to search for. If empty list, use the built-in list of names.

Returns:

The path to the located SConstruct file, or None.

SCons.Script.Main._build_targets(fs, options, targets, target_top)[source]#
SCons.Script.Main._create_path(plist)[source]#
SCons.Script.Main._exec_main(parser, values) None[source]#
SCons.Script.Main._load_all_site_scons_dirs(topdir, verbose: bool = False) None[source]#

Load all of the predefined site_scons dir. Order is significant; we load them in order from most generic (machine-wide) to most specific (topdir). The verbose argument is only for testing.

SCons.Script.Main._load_site_scons_dir(topdir, site_dir_name=None)[source]#

Load the site directory under topdir.

If a site dir name is supplied use it, else use default “site_scons” Prepend site dir to sys.path. If a “site_tools” subdir exists, prepend to toolpath. Import “site_init.py” from site dir if it exists.

SCons.Script.Main._main(parser)[source]#
SCons.Script.Main._scons_internal_error() None[source]#

Handle all errors but user errors. Print out a message telling the user what to do in this case and print a normal trace.

SCons.Script.Main._scons_internal_warning(e) None[source]#

Slightly different from _scons_user_warning in that we use the current call stack rather than sys.exc_info() to get our stack trace. This is used by the warnings framework to print warnings.

SCons.Script.Main._scons_syntax_error(e) None[source]#

Handle syntax errors. Print out a message and show where the error occurred.

SCons.Script.Main._scons_user_error(e) None[source]#

Handle user errors. Print out a message and a description of the error, along with the line number and routine where it occured. The file and line number will be the deepest stack frame that is not part of SCons itself.

SCons.Script.Main._scons_user_warning(e) None[source]#

Handle user warnings. Print out a message and a description of the warning, along with the line number and routine where it occured. The file and line number will be the deepest stack frame that is not part of SCons itself.

SCons.Script.Main._set_debug_values(options) None[source]#
SCons.Script.Main.find_deepest_user_frame(tb)[source]#

Find the deepest stack frame that is not part of SCons.

Input is a “pre-processed” stack trace in the form returned by traceback.extract_tb() or traceback.extract_stack()

SCons.Script.Main.main() None[source]#
SCons.Script.Main.path_string(label, module) str[source]#
SCons.Script.Main.python_version_deprecated(version=sys.version_info(major=3, minor=11, micro=8, releaselevel='final', serial=0))[source]#
SCons.Script.Main.python_version_string()[source]#
SCons.Script.Main.python_version_unsupported(version=sys.version_info(major=3, minor=11, micro=8, releaselevel='final', serial=0))[source]#
SCons.Script.Main.revert_io() None[source]#
SCons.Script.Main.test_load_all_site_scons_dirs(d) None[source]#
SCons.Script.Main.version_string(label, module)[source]#

SCons.Script.SConsOptions module#

SCons.Script.SConsOptions.Parser(version)[source]#

Returns a parser object initialized with the standard SCons options.

Add options in the order we want them to show up in the -H help text, basically alphabetical. Each op.add_option() call should have a consistent format:

op.add_option("-L", "--long-option-name",
              nargs=1, type="string",
              dest="long_option_name", default='foo',
              action="callback", callback=opt_long_option,
              help="help text goes here",
              metavar="VAR")

Even though the optparse module constructs reasonable default destination names from the long option names, we’re going to be explicit about each one for easier readability and so this code will at least show up when grepping the source for option attribute names, or otherwise browsing the source code.

exception SCons.Script.SConsOptions.SConsBadOptionError(opt_str, parser=None)[source]#

Bases: BadOptionError

Exception used to indicate that invalid command line options were specified

Variables:
  • opt_str (str) – The offending option specified on command line which is not recognized

  • parser (OptionParser) – The active argument parser

add_note()#

Exception.add_note(note) – add a note to the exception

args#
with_traceback()#

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class SCons.Script.SConsOptions.SConsIndentedHelpFormatter(indent_increment=2, max_help_position=24, width=None, short_first=1)[source]#

Bases: IndentedHelpFormatter

NO_DEFAULT_VALUE = 'none'#
_format_text(text)#

Format a paragraph of free-form text for inclusion in the help output at the current indentation level.

dedent()#
expand_default(option)#
format_description(description)#
format_epilog(epilog)#
format_heading(heading)[source]#

Translates heading to “SCons Options”

Heading of “Options” changed to “SCons Options.” Unfortunately, we have to do this here, because those titles are hard-coded in the optparse calls.

format_option(option)[source]#

Customized option formatter.

A copy of the normal optparse.IndentedHelpFormatter.format_option() method. This has been snarfed so we can modify text wrapping to our liking:

  • add our own regular expression that doesn’t break on hyphens (so things like --no-print-directory don’t get broken).

  • wrap the list of options themselves when it’s too long (the wrapper.fill(opts) call below).

  • set the subsequent_indent when wrapping the help_text.

The help for each option consists of two parts:

  • the opt strings and metavars e.g. (“-x”, or “-fFILENAME, –file=FILENAME”)

  • the user-supplied help string e.g. (“turn on expert mode”, “read data from FILENAME”)

If possible, we write both of these on the same line:

-x      turn on expert mode

But if the opt string list is too long, we put the help string on a second line, indented to the same column it would start in if it fit on the first line:

-fFILENAME, --file=FILENAME
        read data from FILENAME
format_option_strings(option)#

Return a comma-separated list of option strings & metavariables.

format_usage(usage) str[source]#

Formats the usage message.

indent()#
set_long_opt_delimiter(delim)#
set_parser(parser)#
set_short_opt_delimiter(delim)#
store_local_option_strings(parser, group)[source]#

Local-only version of store_option_strings.

We need to replicate this so the formatter will be set up properly if we didn’t go through the “normal” store_option_strings

New in version 4.6.0.

store_option_strings(parser)#
class SCons.Script.SConsOptions.SConsOption(*opts, **attrs)[source]#

Bases: Option

ACTIONS = ('store', 'store_const', 'store_true', 'store_false', 'append', 'append_const', 'count', 'callback', 'help', 'version')#
ALWAYS_TYPED_ACTIONS = ('store', 'append')#
ATTRS = ['action', 'type', 'dest', 'default', 'nargs', 'const', 'choices', 'callback', 'callback_args', 'callback_kwargs', 'help', 'metavar']#
CHECK_METHODS = [<function Option._check_action>, <function Option._check_type>, <function Option._check_choice>, <function Option._check_dest>, <function Option._check_const>, <function Option._check_nargs>, <function Option._check_callback>, <function SConsOption._check_nargs_optional>]#
CONST_ACTIONS = ('store_const', 'append_const', 'store', 'append', 'callback')#
STORE_ACTIONS = ('store', 'store_const', 'store_true', 'store_false', 'append', 'append_const', 'count')#
TYPED_ACTIONS = ('store', 'append', 'callback')#
TYPES = ('string', 'int', 'long', 'float', 'complex', 'choice')#
TYPE_CHECKER = {'choice': <function check_choice>, 'complex': <function check_builtin>, 'float': <function check_builtin>, 'int': <function check_builtin>, 'long': <function check_builtin>}#
_check_action()#
_check_callback()#
_check_choice()#
_check_const()#
_check_dest()#
_check_nargs()#
_check_nargs_optional()[source]#
_check_opt_strings(opts)#
_check_type()#
_set_attrs(attrs)#
_set_opt_strings(opts)#
check_value(opt, value)#
convert_value(opt, value)[source]#
get_opt_string()#
process(opt, value, values, parser)[source]#
take_action(action, dest, opt, value, values, parser)#
takes_value()#
class SCons.Script.SConsOptions.SConsOptionGroup(parser, title, description=None)[source]#

Bases: OptionGroup

A subclass for SCons-specific option groups.

The only difference between this and the base class is that we print the group’s help text flush left, underneath their own title but lined up with the normal “SCons Options”.

_check_conflict(option)#
_create_option_list()#
_create_option_mappings()#
_share_option_mappings(parser)#
add_option(Option)#
add_option(opt_str, ..., kwarg=val, ...) None
add_options(option_list)#
destroy()#

see OptionParser.destroy().

format_description(formatter)#
format_help(formatter)[source]#

Format an option group’s help text.

The title is dedented so it’s flush with the “SCons Options” title we print at the top.

format_option_help(formatter)#
get_description()#
get_option(opt_str)#
has_option(opt_str)#
remove_option(opt_str)#
set_conflict_handler(handler)#
set_description(description)#
set_title(title)#
class SCons.Script.SConsOptions.SConsOptionParser(usage=None, option_list=None, option_class=<class 'optparse.Option'>, version=None, conflict_handler='error', description=None, formatter=None, add_help_option=True, prog=None, epilog=None)[source]#

Bases: OptionParser

_add_help_option()#
_add_version_option()#
_check_conflict(option)#
_create_option_list()#
_create_option_mappings()#
_get_all_options()#
_get_args(args)#
_init_parsing_state()#
_match_long_opt(opt: string) string#

Determine which long option string ‘opt’ matches, ie. which one it is an unambiguous abbreviation for. Raises BadOptionError if ‘opt’ doesn’t unambiguously match any long option string.

_populate_option_list(option_list, add_help=True)#
_process_args(largs, rargs, values)#
_process_args(largs[string],

rargs : [string], values : Values)

Process command-line arguments and populate ‘values’, consuming options and arguments from ‘rargs’. If ‘allow_interspersed_args’ is false, stop at the first non-option argument. If true, accumulate any interspersed non-option arguments in ‘largs’.

_process_long_opt(rargs, values)[source]#

SCons-specific processing of long options.

This is copied directly from the normal optparse._process_long_opt() method, except that, if configured to do so, we catch the exception thrown when an unknown option is encountered and just stick it back on the “leftover” arguments for later (re-)processing. This is because we may see the option definition later, while processing SConscript files.

_process_short_opts(rargs, values)#
_share_option_mappings(parser)#
add_local_option(*args, **kw)[source]#

Adds a local option to the parser.

This is initiated by an AddOption() call to add a user-defined command-line option. We add the option to a separate option group for the local options, creating the group if necessary.

add_option(Option)#
add_option(opt_str, ..., kwarg=val, ...) None
add_option_group(*args, **kwargs)#
add_options(option_list)#
check_values(values: Values, args: [string])#

-> (values : Values, args : [string])

Check that the supplied option values and leftover arguments are valid. Returns the option values and leftover arguments (possibly adjusted, possibly completely new – whatever you like). Default implementation just returns the passed-in values; subclasses may override as desired.

destroy()#

Declare that you are done with this OptionParser. This cleans up reference cycles so the OptionParser (and all objects referenced by it) can be garbage-collected promptly. After calling destroy(), the OptionParser is unusable.

disable_interspersed_args()#

Set parsing to stop on the first non-option. Use this if you have a command processor which runs another command that has options of its own and you want to make sure these options don’t get confused.

enable_interspersed_args()#

Set parsing to not stop on the first non-option, allowing interspersing switches with command arguments. This is the default behavior. See also disable_interspersed_args() and the class documentation description of the attribute allow_interspersed_args.

error(msg)[source]#

overridden OptionValueError exception handler

exit(status=0, msg=None)#
expand_prog_name(s)#
format_description(formatter)#
format_epilog(formatter)#
format_help(formatter=None)#
format_local_option_help(formatter=None, file=None)[source]#

Return the help for the project-level (“local”) options.

New in version 4.6.0.

format_option_help(formatter=None)#
get_default_values()#
get_description()#
get_option(opt_str)#
get_option_group(opt_str)#
get_prog_name()#
get_usage()#
get_version()#
has_option(opt_str)#
parse_args(args=None, values=None)#
parse_args(args[string] = sys.argv[1:],

values : Values = None)

-> (values : Values, args : [string])

Parse the command-line options found in ‘args’ (default: sys.argv[1:]). Any errors result in a call to ‘error()’, which by default prints the usage message to stderr and calls sys.exit() with an error message. On success returns a pair (values, args) where ‘values’ is a Values instance (with all your option values) and ‘args’ is the list of arguments left over after parsing options.

preserve_unknown_options = False#
print_help(file: file = stdout)#

Print an extended help message, listing all options and any help text provided with them, to ‘file’ (default stdout).

print_local_option_help(file=None)[source]#

Print help for just project-defined options.

Writes to file (default stdout).

New in version 4.6.0.

print_usage(file: file = stdout)#

Print the usage message for the current program (self.usage) to ‘file’ (default stdout). Any occurrence of the string “%prog” in self.usage is replaced with the name of the current program (basename of sys.argv[0]). Does nothing if self.usage is empty or not defined.

print_version(file: file = stdout)#

Print the version message for this program (self.version) to ‘file’ (default stdout). As with print_usage(), any occurrence of “%prog” in self.version is replaced by the current program’s name. Does nothing if self.version is empty or undefined.

raise_exception_on_error = False#
remove_option(opt_str)#
reparse_local_options() None[source]#

Re-parse the leftover command-line options.

Parse options stored in self.largs, so that any value overridden on the command line is immediately available if the user turns around and does a GetOption() right away.

We mimic the processing of the single args in the original OptionParser _process_args(), but here we allow exact matches for long-opts only (no partial argument names!). Otherwise there could be problems in add_local_option() below. When called from there, we try to reparse the command-line arguments that

  1. haven’t been processed so far (self.largs), but

  2. are possibly not added to the list of options yet.

So, when we only have a value for “–myargument” so far, a command-line argument of “–myarg=test” would set it, per the behaviour of _match_long_opt(), which allows for partial matches of the option name, as long as the common prefix appears to be unique. This would lead to further confusion, because we might want to add another option “–myarg” later on (see issue #2929).

set_conflict_handler(handler)#
set_default(dest, value)#
set_defaults(**kwargs)#
set_description(description)#
set_process_default_values(process)#
set_usage(usage)#
standard_option_list = []#
class SCons.Script.SConsOptions.SConsValues(defaults)[source]#

Bases: Values

Holder class for uniform access to SCons options, regardless of whether they can be set on the command line or in the SConscript files (using the SetOption() function).

A SCons option value can originate three different ways:

  1. set on the command line;

  2. set in an SConscript file;

  3. the default setting (from the the op.add_option() calls in the Parser() function, below).

The command line always overrides a value set in a SConscript file, which in turn always overrides default settings. Because we want to support user-specified options in the SConscript file itself, though, we may not know about all of the options when the command line is first parsed, so we can’t make all the necessary precedence decisions at the time the option is configured.

The solution implemented in this class is to keep these different sets of settings separate (command line, SConscript file, and default) and to override the __getattr__() method to check them in turn. This should allow the rest of the code to just fetch values as attributes of an instance of this class, without having to worry about where they came from.

Note that not all command line options are settable from SConscript files, and the ones that are must be explicitly added to the “settable” list in this class, and optionally validated and coerced in the set_option() method.

__getattr__(attr)[source]#

Fetches an options value, checking first for explicit settings from the command line (which are direct attributes), then the SConscript file settings, then the default values.

_update(dict, mode)#
_update_careful(dict)#

Update the option values from an arbitrary dictionary, but only use keys from dict that already have a corresponding attribute in self. Any keys in dict without a corresponding attribute are silently ignored.

_update_loose(dict)#

Update the option values from an arbitrary dictionary, using all keys from the dictionary regardless of whether they have a corresponding attribute in self or not.

ensure_value(attr, value)#
read_file(filename, mode='careful')#
read_module(modname, mode='careful')#
set_option(name, value)[source]#

Sets an option from an SConscript file.

Raises:

UserError – invalid or malformed option (“error in your script”)

settable = ['clean', 'diskcheck', 'duplicate', 'experimental', 'hash_chunksize', 'hash_format', 'help', 'implicit_cache', 'implicit_deps_changed', 'implicit_deps_unchanged', 'max_drift', 'md5_chunksize', 'no_exec', 'no_progress', 'num_jobs', 'random', 'silent', 'stack_size', 'warn', 'disable_execute_ninja', 'disable_ninja', 'skip_ninja_regen']#
SCons.Script.SConsOptions.diskcheck_convert(value)[source]#

SCons.Script.SConscript module#

This module defines the Python API provided to SConscript files.

SCons.Script.SConscript.BuildDefaultGlobals()[source]#

Create a dictionary containing all the default globals for SConstruct and SConscript files.

SCons.Script.SConscript.Configure(*args, **kw)[source]#
class SCons.Script.SConscript.DefaultEnvironmentCall(method_name, subst: int = 0)[source]#

Bases: object

A class that implements “global function” calls of Environment methods by fetching the specified method from the DefaultEnvironment’s class. Note that this uses an intermediate proxy class instead of calling the DefaultEnvironment method directly so that the proxy can override the subst() method and thereby prevent expansion of construction variables (since from the user’s point of view this was called as a global function, with no associated construction environment).

class SCons.Script.SConscript.Frame(fs, exports, sconscript)[source]#

Bases: object

A frame on the SConstruct/SConscript call stack

SCons.Script.SConscript.Return(*vars, **kw)[source]#
class SCons.Script.SConscript.SConsEnvironment(platform=None, tools=None, toolpath=None, variables=None, parse_flags=None, **kw)[source]#

Bases: Base

An Environment subclass that contains all of the methods that are particular to the wrapper SCons interface and which aren’t (or shouldn’t be) part of the build engine itself.

Note that not all of the methods of this class have corresponding global functions, there are some private methods.

Action(*args, **kw)#
AddMethod(function, name=None) None#

Adds the specified function as a method of this construction environment with the specified name. If the name is omitted, the default name is the name of the function itself.

AddPostAction(files, action)#
AddPreAction(files, action)#
Alias(target, source=[], action=None, **kw)#
AlwaysBuild(*targets)#
Append(**kw) None#

Append values to construction variables in an Environment.

The variable is created if it is not already present.

AppendENVPath(name, newpath, envname: str = 'ENV', sep=':', delete_existing: bool = False) None#

Append path elements to the path name in the envname dictionary for this environment. Will only add any particular path once, and will normpath and normcase all paths to help assure this. This can also handle the case where the env variable is a list instead of a string.

If delete_existing is False, a newpath element already in the path will not be moved to the end (it will be left where it is).

AppendUnique(delete_existing: bool = False, **kw) None#

Append values to existing construction variables in an Environment, if they’re not already there. If delete_existing is True, removes existing values first, so values move to end.

Builder(**kw)#
CacheDir(path, custom_class=None) None#
Clean(targets, files) None#
Clone(tools=[], toolpath=None, parse_flags=None, **kw)#

Return a copy of a construction Environment.

The copy is like a Python “deep copy”–that is, independent copies are made recursively of each objects–except that a reference is copied when an object is not deep-copyable (like a function). There are no references to any mutable objects in the original Environment.

Command(target, source, action, **kw)#

Builds the supplied target files from the supplied source files using the supplied action. Action may be any type that the Builder constructor will accept for an action.

Configure(*args, **kw)[source]#
Decider(function)#
Default(*targets) None[source]#
Depends(target, dependency)#

Explicity specify that ‘target’s depend on ‘dependency’.

Detect(progs)#

Return the first available program from one or more possibilities.

Parameters:

progs (str or list) – one or more command names to check for

Dictionary(*args)#

Return construction variables from an environment.

Parameters:

*args (optional) – variable names to look up

Returns:

If args omitted, the dictionary of all construction variables. If one arg, the corresponding value is returned. If more than one arg, a list of values is returned.

Raises:

KeyError – if any of args is not in the construction environment.

Dir(name, *args, **kw)#
Dump(key=None, format: str = 'pretty')#

Return construction variables serialized to a string.

Parameters:
  • key (optional) – if None, format the whole dict of variables. Else format the value of key (Default value = None)

  • format (str, optional) – specify the format to serialize to. “pretty” generates a pretty-printed string, “json” a JSON-formatted string. (Default value = “pretty”)

static EnsurePythonVersion(major, minor) None[source]#

Exit abnormally if the Python version is not late enough.

static EnsureSConsVersion(major, minor, revision: int = 0) None[source]#

Exit abnormally if the SCons version is not late enough.

Entry(name, *args, **kw)#
Environment(**kw)#
Execute(action, *args, **kw)#

Directly execute an action through an Environment

static Exit(value: int = 0) None[source]#
Export(*vars, **kw) None[source]#
File(name, *args, **kw)#
FindFile(file, dirs)#
FindInstalledFiles()#

returns the list of all targets of the Install and InstallAs Builder.

FindIxes(paths, prefix, suffix)#

Search a list of paths for something that matches the prefix and suffix.

Parameters:
  • paths – the list of paths or nodes.

  • prefix – construction variable for the prefix.

  • suffix – construction variable for the suffix.

Returns: the matched path or None

FindSourceFiles(node: str = '.') list#

Return a list of all source files.

Flatten(sequence)#
GetBuildPath(files)#
static GetLaunchDir()[source]#
GetOption(name)[source]#
Glob(pattern, ondisk: bool = True, source: bool = False, strings: bool = False, exclude=None)#
Help(text, append: bool = False, keep_local: bool = False) None[source]#

Update the help text.

The previous help text has text appended to it, except on the first call. On first call, the values of append and keep_local are considered to determine what is appended to.

Parameters:
  • text – string to add to the help text.

  • append – on first call, if true, keep the existing help text (default False).

  • keep_local – on first call, if true and append is also true, keep only the help text from AddOption calls.

Changed in version 4.6.0: The keep_local parameter was added.

Ignore(target, dependency)#

Ignore a dependency.

Import(*vars)[source]#
Literal(string)#
Local(*targets)#
MergeFlags(args, unique: bool = True) None#

Merge flags into construction variables.

Merges the flags from args into this construction environent. If args is not a dict, it is first converted to one with flags distributed into appropriate construction variables. See ParseFlags().

As a side effect, if unique is true, a new object is created for each modified construction variable by the loop at the end. This is silently expected by the Override() parse_flags functionality, which does not want to share the list (or whatever) with the environment being overridden.

Parameters:
  • args – flags to merge

  • unique – merge flags rather than appending (default: True). When merging, path variables are retained from the front, other construction variables from the end.

NoCache(*targets)#

Tags a target so that it will not be cached

NoClean(*targets)#

Tags a target so that it will not be cleaned by -c

Override(overrides)#

Produce a modified environment whose variables are overridden by the overrides dictionaries. “overrides” is a dictionary that will override the variables of this environment.

This function is much more efficient than Clone() or creating a new Environment because it doesn’t copy the construction environment dictionary, it just wraps the underlying construction environment, and doesn’t even create a wrapper object if there are no overrides.

ParseConfig(command, function=None, unique: bool = True)#

Parse the result of running a command to update construction vars.

Use function to parse the output of running command in order to modify the current environment.

Parameters:
  • command – a string or a list of strings representing a command and its arguments.

  • function – called to process the result of command, which will be passed as args. If function is omitted or None, MergeFlags() is used. Takes 3 args (env, args, unique)

  • unique – whether no duplicate values are allowed (default true)

ParseDepends(filename, must_exist=None, only_one: bool = False)#

Parse a mkdep-style file for explicit dependencies. This is completely abusable, and should be unnecessary in the “normal” case of proper SCons configuration, but it may help make the transition from a Make hierarchy easier for some people to swallow. It can also be genuinely useful when using a tool that can write a .d file, but for which writing a scanner would be too complicated.

ParseFlags(*flags) dict#

Return a dict of parsed flags.

Parse flags and return a dict with the flags distributed into the appropriate construction variable names. The flags are treated as a typical set of command-line flags for a GNU-style toolchain, such as might have been generated by one of the {foo}-config scripts, and used to populate the entries based on knowledge embedded in this method - the choices are not expected to be portable to other toolchains.

If one of the flags strings begins with a bang (exclamation mark), it is assumed to be a command and the rest of the string is executed; the result of that evaluation is then added to the dict.

Platform(platform)#
Precious(*targets)#

Mark targets as precious: do not delete before building.

Prepend(**kw) None#

Prepend values to construction variables in an Environment.

The variable is created if it is not already present.

PrependENVPath(name, newpath, envname: str = 'ENV', sep=':', delete_existing: bool = True) None#

Prepend path elements to the path name in the envname dictionary for this environment. Will only add any particular path once, and will normpath and normcase all paths to help assure this. This can also handle the case where the env variable is a list instead of a string.

If delete_existing is False, a newpath component already in the path will not be moved to the front (it will be left where it is).

PrependUnique(delete_existing: bool = False, **kw) None#

Prepend values to existing construction variables in an Environment, if they’re not already there. If delete_existing is True, removes existing values first, so values move to front.

Pseudo(*targets)#

Mark targets as pseudo: must not exist.

PyPackageDir(modulename)#
RemoveMethod(function) None#

Removes the specified function’s MethodWrapper from the added_methods list, so we don’t re-bind it when making a clone.

Replace(**kw) None#

Replace existing construction variables in an Environment with new construction variables and/or values.

ReplaceIxes(path, old_prefix, old_suffix, new_prefix, new_suffix)#

Replace old_prefix with new_prefix and old_suffix with new_suffix.

env - Environment used to interpolate variables. path - the path that will be modified. old_prefix - construction variable for the old prefix. old_suffix - construction variable for the old suffix. new_prefix - construction variable for the new prefix. new_suffix - construction variable for the new suffix.

Repository(*dirs, **kw) None#

Specify Repository directories to search.

Requires(target, prerequisite)#

Specify that prerequisite must be built before target.

Creates an order-only relationship, not a full dependency. prerequisite must exist before target can be built, but a change to prerequisite does not trigger a rebuild of target.

SConscript(*ls, **kw)[source]#

Execute SCons configuration files.

Parameters:

*ls (str or list) – configuration file(s) to execute.

Keyword Arguments:
  • dirs (list) – execute SConscript in each listed directory.

  • name (str) – execute script ‘name’ (used only with ‘dirs’).

  • exports (list or dict) – locally export variables the called script(s) can import.

  • variant_dir (str) – mirror sources needed for the build in a variant directory to allow building in it.

  • duplicate (bool) – physically duplicate sources instead of just adjusting paths of derived files (used only with ‘variant_dir’) (default is True).

  • must_exist (bool) – fail if a requested script is missing (default is False, default is deprecated).

Returns:

list of variables returned by the called script

Raises:

UserError – a script is not found and such exceptions are enabled.

static SConscriptChdir(flag: bool) None[source]#
SConsignFile(name='.sconsign', dbm_module=None) None#
Scanner(*args, **kw)#
SetDefault(**kw) None#
SetOption(name, value) None[source]#
SideEffect(side_effect, target)#

Tell scons that side_effects are built as side effects of building targets.

Split(arg)#

This function converts a string or list into a list of strings or Nodes. This makes things easier for users by allowing files to be specified as a white-space separated list to be split.

The input rules are:
  • A single string containing names separated by spaces. These will be split apart at the spaces.

  • A single Node instance

  • A list containing either strings or Node instances. Any strings in the list are not split at spaces.

In all cases, the function returns a list of Nodes and strings.

Tool(tool, toolpath=None, **kwargs) Tool#

Find and run tool module tool.

Changed in version 4.2: returns the tool module rather than None.

Value(value, built_value=None, name=None)#

Return a Value (Python expression) node.

Changed in version 4.0: the name parameter was added.

VariantDir(variant_dir, src_dir, duplicate: int = 1) None#
WhereIs(prog, path=None, pathext=None, reject=None)#

Find prog in the path.

_canonicalize(path)#

Allow Dirs and strings beginning with # for top-relative.

Note this uses the current env’s fs (in self).

_changed_build(dependency, target, prev_ni, repo_node=None) bool#
_changed_content(dependency, target, prev_ni, repo_node=None) bool#
_changed_timestamp_match(dependency, target, prev_ni, repo_node=None) bool#
_changed_timestamp_newer(dependency, target, prev_ni, repo_node=None) bool#
_changed_timestamp_then_content(dependency, target, prev_ni, repo_node=None) bool#
_find_toolpath_dir(tp)#
_get_SConscript_filenames(ls, kw)[source]#

Convert the parameters passed to SConscript() calls into a list of files and export variables. If the parameters are invalid, throws SCons.Errors.UserError. Returns a tuple (l, e) where l is a list of SConscript filenames and e is a list of exports.

static _get_major_minor_revision(version_string)[source]#

Split a version string into major, minor and (optionally) revision parts.

This is complicated by the fact that a version string can be something like 3.2b1.

_gsm()#
_init_special() None#

Initial the dispatch tables for special handling of special construction variables.

_update(other) None#

Private method to update an environment’s consvar dict directly.

Bypasses the normal checks that occur when users try to set items.

_update_onlynew(other) None#

Private method to add new items to an environment’s consvar dict.

Only adds items from other whose keys do not already appear in the existing dict; values from other are not used for replacement. Bypasses the normal checks that occur when users try to set items.

arg2nodes(args, node_factory=<class 'SCons.Environment._Null'>, lookup_list=<class 'SCons.Environment._Null'>, **kw)#

Converts args to a list of nodes.

Parameters:
  • just (args - filename strings or nodes to convert; nodes are) – added to the list without further processing.

  • not (node_factory - optional factory to create the nodes; if) – specified, will use this environment’s ``fs.File method.

  • to (lookup_list - optional list of lookup functions to call) – attempt to find the file referenced by each args.

  • add. (kw - keyword arguments that represent additional nodes to) –

backtick(command) str#

Emulate command substitution.

Provides behavior conceptually like POSIX Shell notation for running a command in backquotes (backticks) by running command and returning the resulting output string.

This is not really a public API any longer, it is provided for the use of ParseFlags() (which supports it using a syntax of !command) and ParseConfig().

Raises:

OSError – if the external command returned non-zero exit status.

get(key, default=None)#

Emulates the get() method of dictionaries.

get_CacheDir()#
get_builder(name)#

Fetch the builder with the specified name from the environment.

get_factory(factory, default: str = 'File')#

Return a factory function for creating Nodes for this construction environment.

get_scanner(skey)#

Find the appropriate scanner given a key (usually a file suffix).

gvars()#
items()#

Emulates the items() method of dictionaries.

keys()#

Emulates the keys() method of dictionaries.

lvars()#
scanner_map_delete(kw=None) None#

Delete the cached scanner map (if we need to).

setdefault(key, default=None)#

Emulates the setdefault() method of dictionaries.

subst(string, raw: int = 0, target=None, source=None, conv=None, executor: Executor | None = None, overrides: dict | None = None)#

Recursively interpolates construction variables from the Environment into the specified string, returning the expanded result. Construction variables are specified by a $ prefix in the string and begin with an initial underscore or alphabetic character followed by any number of underscores or alphanumeric characters. The construction variable names may be surrounded by curly braces to separate the name from trailing characters.

subst_kw(kw, raw: int = 0, target=None, source=None)#
subst_list(string, raw: int = 0, target=None, source=None, conv=None, executor: Executor | None = None, overrides: dict | None = None)#

Calls through to SCons.Subst.scons_subst_list().

See the documentation for that function.

subst_path(path, target=None, source=None)#

Substitute a path list.

Turns EntryProxies into Nodes, leaving Nodes (and other objects) as-is.

subst_target_source(string, raw: int = 0, target=None, source=None, conv=None, executor: Executor | None = None, overrides: dict | None = None)#

Recursively interpolates construction variables from the Environment into the specified string, returning the expanded result. Construction variables are specified by a $ prefix in the string and begin with an initial underscore or alphabetic character followed by any number of underscores or alphanumeric characters. The construction variable names may be surrounded by curly braces to separate the name from trailing characters.

validate_CacheDir_class(custom_class=None)#

Validate the passed custom CacheDir class, or if no args are passed, validate the custom CacheDir class from the environment.

values()#

Emulates the values() method of dictionaries.

exception SCons.Script.SConscript.SConscriptReturn[source]#

Bases: Exception

add_note()#

Exception.add_note(note) – add a note to the exception

args#
with_traceback()#

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

SCons.Script.SConscript.SConscript_exception(file=<_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>) None[source]#

Print an exception stack trace just for the SConscript file(s). This will show users who have Python errors where the problem is, without cluttering the output with all of the internal calls leading up to where we exec the SConscript.

SCons.Script.SConscript._SConscript(fs, *files, **kw)[source]#
SCons.Script.SConscript.annotate(node)[source]#

Annotate a node with the stack frame describing the SConscript file and line number that created it.

SCons.Script.SConscript.compute_exports(exports)[source]#

Compute a dictionary of exports given one of the parameters to the Export() function or the exports argument to SConscript().

SCons.Script.SConscript.get_DefaultEnvironmentProxy()[source]#
SCons.Script.SConscript.get_calling_namespaces()[source]#

Return the locals and globals for the function that called into this module in the current call stack.

SCons.Script.SConscript.handle_missing_SConscript(f: str, must_exist: bool = True) None[source]#

Take appropriate action on missing file in SConscript() call.

Print a warning or raise an exception on missing file, unless missing is explicitly allowed by the must_exist parameter or by a global flag.

Parameters:
  • f – path to missing configuration file

  • must_exist – if true (the default), fail. If false do nothing, allowing a build to declare it’s okay to be missing.

Raises:

UserError – if must_exist is true or if global SCons.Script._no_missing_sconscript is true.

Module contents#

The main() function used by the scons script.

Architecturally, this is the scons script, and will likely only be called from the external “scons” wrapper. Consequently, anything here should not be, or be considered, part of the build engine. If it’s something that we expect other software to want to use, it should go in some other module. If it’s specific to the “scons” script invocation, it goes here.

SCons.Script.HelpFunction(text, append: bool = False, keep_local: bool = False) None[source]#

The implementaion of the the Help method.

See Help().

Changed in version 4.6.0: The keep_local parameter was added.

class SCons.Script.TargetList(initlist=None)[source]#

Bases: UserList

_abc_impl = <_abc._abc_data object>#
_add_Default(list) None[source]#
_clear() None[source]#
_do_nothing(*args, **kw) None[source]#
append(item)#

S.append(value) – append value to the end of the sequence

clear() None -- remove all items from S#
copy()#
count(value) integer -- return number of occurrences of value#
extend(other)#

S.extend(iterable) – extend sequence by appending elements from the iterable

index(value[, start[, stop]]) integer -- return first index of value.#

Raises ValueError if the value is not present.

Supporting start and stop arguments is optional, but recommended.

insert(i, item)#

S.insert(index, value) – insert value before index

pop([index]) item -- remove and return item at index (default last).#

Raise IndexError if list is empty or index is out of range.

remove(item)#

S.remove(value) – remove first occurrence of value. Raise ValueError if the value is not present.

reverse()#

S.reverse() – reverse IN PLACE

sort(*args, **kwds)#
SCons.Script.Variables(files=None, args={})[source]#
SCons.Script._Add_Arguments(alist) None[source]#
SCons.Script._Add_Targets(tlist) None[source]#
SCons.Script._Get_Default_Targets(d, fs)#
SCons.Script._Set_Default_Targets(env, tlist) None[source]#
SCons.Script._Set_Default_Targets_Has_Been_Called(d, fs)[source]#
SCons.Script._Set_Default_Targets_Has_Not_Been_Called(d, fs)[source]#
SCons.Script.set_missing_sconscript_error(flag: bool = True) bool[source]#

Set behavior on missing file in SConscript() call.

Returns:

previous value