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

William Deegan bill at baddogconsulting.com
Mon Jul 15 15:13:52 EDT 2013


Andrew,

On Jul 10, 2013, at 11:34 AM, Andrew C. Morrow <andrew.c.morrow at gmail.com> wrote:


> 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

> file.

>

> 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

> too.


Using your script sounds like a good solution, you may just want to try to propagate the shell environment's PATH and/or path to the invoked scons to the shell which invokes your script.
I'd create a new or clone an existing Environment and change it's path to be correct to get the "right" scons.

Trying to reinvoke scons from which scons in code is probably a bad idea.
(more complicated/etc)

-Bill


More information about the Scons-users mailing list