import os.path, SCons
-# SCons is at #/scons/scons-<v>/engine/SCons/__init__.py
+# SCons is at #/tools/scons-<v>/engine/SCons/__init__.py
# site_init is at #/site_scons/site_init.py
-sconsbase = os.path.join(os.path.dirname(os.path.dirname(__file__)),"scons")
-sconsbase = os.path.abspath(os.path.join(sconsbase, sorted(os.listdir(sconsbase))[-1]))
+sconsbase = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))),"tools")
+sconsbase = os.path.join(
+ sconsbase,sorted((f for f in os.listdir(sconsbase) if f.startswith("scons-")))[-1])
sconsengine = os.path.join(sconsbase, 'engine')
-sconsscript = os.path.join(os.path.join(sconsbase, 'script'),'scons')
+sconsscript = os.path.join(sconsbase, 'script', 'scons')
-if os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(SCons.__file__)))) != sconsbase:
+if os.path.dirname(os.path.dirname(os.path.abspath(SCons.__file__))) != sconsengine:
import os, sys, SCons.Util
SCons.Util.display("scons: Switching version")