3 # SCons is at #/scons/scons-<v>/engine/SCons/__init__.py
4 # site_init is at #/site_scons/site_init.py
6 sconsbase = os.path.join(os.path.dirname(os.path.dirname(__file__)),"scons")
7 sconsbase = os.path.abspath(os.path.join(sconsbase, sorted(os.listdir(sconsbase))[-1]))
8 sconsengine = os.path.join(sconsbase, 'engine')
9 sconsscript = os.path.join(os.path.join(sconsbase, 'script'),'scons')
11 if os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(SCons.__file__)))) != sconsbase:
12 import os, sys, SCons.Util
13 SCons.Util.display("scons: Switching version")
16 # This is really ugly. SCons has already switched into the
17 # top-level directory when this code is executed. To make 'scons
18 # -u <target>' work, we need to switch back into the orgiginal
19 # startup dir. This directory however is only available in a local
20 # variable called 'target_top' in SCons.Script.Main._main.
22 # We walk the stack to find a local variable called
23 # 'target_top'. If we can't find it (could really only happen if
24 # the SCons.Main code is changed considerably), we output a
25 # warning, that '-u' will probably fail (we re-start scons from
26 # the top-level directory, relative targets therefore will not
28 frame = sys._getframe()
29 target_top = marker = []
30 while frame and target_top is marker:
31 target_top = frame.f_locals.get('target_top',marker)
33 if target_top is marker:
34 SCons.Util.display("scons: WARNING: scons -u <target> will probably fail")
40 os.environ['SCONS_LIB_DIR'] = sconsengine
41 os.execv(sconsscript, sys.argv)