[Scons-users] How to find the directory of the invoking SConstruct

Russell, J.J. russell at slac.stanford.edu
Sat Jul 13 16:44:00 EDT 2013

For a variety of reasons, we discourage folk from cd'ing into directory where the SConstruct file lives to invoke the build. They have a tendency to drop crud in the directory, or worse, of accidentally invoking "rm *" via careless command line recall actions.

We would prefer that they invoke the command using the -f <file> command line option, where 'file' usually includes a directory path. However, when doing this relative paths within the SConstruct file are misinterpreted, e.g., SConscript ('src/Sconscript') fails. This is certainly consistent with SCons not 'cd'ing into the SConstruct directory ala 'make'.

One way that works is -C<directory> followed by -f<file-name>. This seems a little clunky, but, if that's the way it is intended to work, then okay. I just worry that a user mistakenly specifying the full path to the SConstruct file via -f will be, at best, frustrated and, at worst, get something he did not bargain for.

I want to make sure I am not missing the correct/intended way to do this.


More information about the Scons-users mailing list