[Scons-users] Getting directory in which Sconscript is running
Gary Oberbrunner
garyo at oberbrunner.com
Thu May 1 12:27:37 EDT 2014
On Thu, May 1, 2014 at 11:48 AM, Tom Tanner (BLOOMBERG/ LONDON)
<ttanner2 at bloomberg.net> wrote:
>
> I'd really like to be able to get hold of the current SConscript directory relative to the SConstruct path, so with a directory structure in a repository a little like this:
> ....
>
> There will be something I can do in the SConscript that will get me "A/B" (i.e. the relative directory in which things will be built), and <wherever the source is>/A/B, which is the sort of thing I need to stuff in environment variable (for instance for getting the right PYTHONPATH for running python scripts which live in a subdirectory of B).
>
> Using Dir('.').rstr() or .rdir() will get you '.'. Throwing srcdir().abspath into the mix will get me the full path to the build directory, not the full path to the source directory.
This may or may not help, but Dir('.') in the SConscript dir will,
when stringified, give '.' while reading the SConscript, but 'A/B'
during the actual build, because the path is relative to the current
dir at that time, and when a SConscript it being read, its dir is the
cwd, but when building, top is always the cwd. So if you can delay
converting Dir('.') to a path until build time, it should just work.
--
Gary
More information about the Scons-users
mailing list