summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Deegan <bill@baddogconsulting.com>2017-10-14 21:33:54 (GMT)
committerGitHub <noreply@github.com>2017-10-14 21:33:54 (GMT)
commit351c325f5ee49b322b625812142a8c042ffe723a (patch)
tree2e88edebb251f8da3ce9f862916606e06f00af6f
parent23e7e0cedcda42be0f430ff1efcfa20f983d9cc5 (diff)
parent874dba0c35cd8f6459ddbdfcdaf8be12307cd038 (diff)
downloadSCons-351c325f5ee49b322b625812142a8c042ffe723a.zip
SCons-351c325f5ee49b322b625812142a8c042ffe723a.tar.gz
SCons-351c325f5ee49b322b625812142a8c042ffe723a.tar.bz2
Merge pull request #14 from bdbaddog/fix_py3_syspath_explosion
Fix issue with Tool loading logic where sys.path was getting an addition site_scons/site_tools path prepended with every tool loaded when running with Python 3.5+.
-rw-r--r--src/CHANGES.txt1
-rw-r--r--src/engine/SCons/Tool/__init__.py10
2 files changed, 9 insertions, 2 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index cbb9cff..373a9b3 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -22,6 +22,7 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
- Fixed Variables.GenerateHelpText() to now use the sort parameter. Due to incorrect 2to3 fixer changes
8 years ago it was being used as a boolean parameter. Now you can specify sort to be a callable, or boolean
value. (True = normal sort). Manpage also updated.
+ - Fixed Tool loading logic from exploding sys.path with many site_scons/site_tools prepended on py3.
From Thomas Berg:
- Fixed a regression in scons-3.0.0 where "from __future__ import print_function" was imposed
diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py
index 57090bb..a4e44a0 100644
--- a/src/engine/SCons/Tool/__init__.py
+++ b/src/engine/SCons/Tool/__init__.py
@@ -222,8 +222,10 @@ class Tool(object):
# Don't reload a tool we already loaded.
sys_modules_value = sys.modules.get(found_name,False)
+
+ found_module = None
if sys_modules_value and sys_modules_value.__file__ == spec.origin:
- return sys.modules[found_name]
+ found_module = sys.modules[found_name]
else:
# Not sure what to do in the case that there already
# exists sys.modules[self.name] but the source file is
@@ -235,7 +237,11 @@ class Tool(object):
# If we found it in SCons.Tool, then add it to the module
setattr(SCons.Tool, self.name, module)
- return module
+ found_module = module
+
+ if found_module is not None:
+ sys.path = oldpythonpath
+ return found_module
sys.path = oldpythonpath