[Scons-users] How can I re-invoke the currently running SCons from within a SConscript?

Andrew C. Morrow andrew.c.morrow at gmail.com
Wed Jul 10 11:34:01 EDT 2013

A long description follows for context; the real question is at the end...

I have a project which generates a tar.gz file as a build artifact.
This archive contains a set of source files and its own SConstruct

I would like, as part of testing the project, to ensure that the
tar.gz artifact is correctly made. This involves extracting it to a
temporary directory and invoking SCons with the SConstruct file from
the archive.

Currently, this is accomplished by having the main project SConscript
invoke an external python script, which in turn builds a command line
beginning with the string 'scons', which is then executed with
python's subprocess.call. As a result the 'scons' that will be invoked
here will be looked up via normal path search.

The problem with the above is that the 'scons' found in the last step
may not be the same scons that was used to invoke the overall build.
Or, there may be no 'scons' on the path at all, especially if the top
level scons invocation was an invocation of a SCons installation
residing in a non-standard location.

I'd like to simplify this process by eliminating the separate python
script and moving the logic from that script into the top level
project's SConscript. While doing so, I'd like to solve the problem
with the path lookup: I'd like to ensure that whatever SCons was used
to invoke the top level build is also used to invoke the test build of
the archive.

How can I, within a SConscript file, re-invoke whatever 'scons' is
currently being run? Presumably, I'll need to pass it some options


More information about the Scons-users mailing list