summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRussel Winder <russel@winder.org.uk>2017-06-20 18:52:32 (GMT)
committerRussel Winder <russel@winder.org.uk>2017-06-20 18:52:32 (GMT)
commit101e9c489f35cd2c1aa92121faf0d8e8d54cc080 (patch)
tree64c754aae02b51521040b352ba2a94b4d2954d34 /src
parentf682d3b5d89b2a37d8743966206a6da303812528 (diff)
parent8058b1600eff989c685ed5dbc660133f3c8ddf08 (diff)
downloadSCons-101e9c489f35cd2c1aa92121faf0d8e8d54cc080.zip
SCons-101e9c489f35cd2c1aa92121faf0d8e8d54cc080.tar.gz
SCons-101e9c489f35cd2c1aa92121faf0d8e8d54cc080.tar.bz2
Merge in mainline.
Diffstat (limited to 'src')
-rw-r--r--src/CHANGES.txt4
-rw-r--r--src/engine/SCons/Tool/__init__.py28
2 files changed, 24 insertions, 8 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index 537aca3..745c69d 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -7,6 +7,10 @@
RELEASE 3.0.0.alpha.20170614 - Mon, 14 Jun 2017 12:23:56 -0400
+ From Richard West:
+ - Added nested / namespace tool support
+ - Added a small fix to the python3 tool loader when loading a tool as a package
+
From William Blevins:
- Updated D language scanner support to latest: 2.071.1. (PR #1924)
https://dlang.org/spec/module.html accessed 11 August 2016
diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py
index 61b7788..e5b4b05 100644
--- a/src/engine/SCons/Tool/__init__.py
+++ b/src/engine/SCons/Tool/__init__.py
@@ -118,6 +118,16 @@ class Tool(object):
if hasattr(module, 'options'):
self.options = module.options
+ def _load_dotted_module_py2(self, short_name, full_name, searchpaths=None):
+ splitname = short_name.split('.')
+ index = 0
+ srchpths = searchpaths
+ for item in splitname:
+ file, path, desc = imp.find_module(item, srchpths)
+ mod = imp.load_module(full_name, file, path, desc)
+ srchpths = [path]
+ return mod, file
+
def _tool_module(self):
oldpythonpath = sys.path
sys.path = self.toolpath + sys.path
@@ -127,15 +137,16 @@ class Tool(object):
# Py 2 code
try:
try:
- file, path, desc = imp.find_module(self.name, self.toolpath)
+ file = None
try:
- return imp.load_module(self.name, file, path, desc)
-
+ mod, file = self._load_dotted_module_py2(self.name, self.name, self.toolpath)
+ return mod
finally:
if file:
file.close()
except ImportError as e:
- if str(e)!="No module named %s"%self.name:
+ splitname = self.name.split('.')
+ if str(e)!="No module named %s"%splitname[0]:
raise SCons.Errors.EnvironmentError(e)
try:
import zipimport
@@ -169,8 +180,9 @@ class Tool(object):
found_name = self.name
add_to_scons_tools_namespace = False
for path in self.toolpath:
- file_path = os.path.join(path, "%s.py"%self.name)
- file_package = os.path.join(path, self.name)
+ sepname = self.name.replace('.', os.path.sep)
+ file_path = os.path.join(path, "%s.py"%sepname)
+ file_package = os.path.join(path, sepname)
if debug: sys.stderr.write("Trying:%s %s\n"%(file_path, file_package))
@@ -179,6 +191,7 @@ class Tool(object):
if debug: print("file_Path:%s FOUND"%file_path)
break
elif os.path.isdir(file_package):
+ file_package = os.path.join(file_package, '__init__.py')
spec = importlib.util.spec_from_file_location(self.name, file_package)
if debug: print("PACKAGE:%s Found"%file_package)
break
@@ -231,8 +244,7 @@ class Tool(object):
try:
smpath = sys.modules['SCons.Tool'].__path__
try:
- file, path, desc = imp.find_module(self.name, smpath)
- module = imp.load_module(full_name, file, path, desc)
+ module, file = self._load_dotted_module_py2(self.name, full_name, smpath)
setattr(SCons.Tool, self.name, module)
if file:
file.close()