summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Gross <grossag@vmware.com>2020-11-16 16:35:21 (GMT)
committerAdam Gross <grossag@vmware.com>2020-11-16 16:35:21 (GMT)
commit69ab257c530f6449a4ec49454500c507437a9dbc (patch)
tree5991a83d0b6fdd8b992b172a0329767eeb419b99
parentfde36127ff949e7efbce321e7ace07707b35e41a (diff)
downloadSCons-69ab257c530f6449a4ec49454500c507437a9dbc.zip
SCons-69ab257c530f6449a4ec49454500c507437a9dbc.tar.gz
SCons-69ab257c530f6449a4ec49454500c507437a9dbc.tar.bz2
Fix up scanner a bit
Tests still break
-rw-r--r--SCons/Scanner/Python.py16
-rw-r--r--test/Scanner/Python.py2
2 files changed, 11 insertions, 7 deletions
diff --git a/SCons/Scanner/Python.py b/SCons/Scanner/Python.py
index 63f5035..5f51a7c 100644
--- a/SCons/Scanner/Python.py
+++ b/SCons/Scanner/Python.py
@@ -92,10 +92,14 @@ def scan(node, env, path=()):
# if the same header is included many times.
node.includes = list(map(SCons.Util.silent_intern, includes))
- # XXX TODO: Sort?
nodes = []
if callable(path):
path = path()
+
+ # If there are no paths, there is no point in parsing includes in the loop.
+ if not path:
+ return []
+
for module, imports in includes:
is_relative = module.startswith('.')
if is_relative:
@@ -111,7 +115,7 @@ def scan(node, env, path=()):
search_paths = [current_dir]
search_string = module_lstripped
else:
- search_paths = [env.Dir(p) for p in tuple(path)]
+ search_paths = [env.Dir(p) for p in path]
search_string = module
module_components = search_string.split('.')
@@ -123,8 +127,8 @@ def scan(node, env, path=()):
# lower in the search_paths precedence order. As a result, it is safest
# to iterate over search_paths and check whether p or p.py exists in
# each path. This allows us to cleanly respect the precedence order.
- for path in search_paths:
- paths = [path]
+ for search_path in search_paths:
+ paths = [search_path]
node = SCons.Node.FS.find_file(module_joined, paths, verbose=True)
if node:
# The fact that we were able to find the node without appending .py
@@ -136,7 +140,6 @@ def scan(node, env, path=()):
# import, we don't need to take the dependency because Python
# requires that all referenced packages have already been imported,
# which means that the dependency has already been established.
- # XXX TODO: This part is broken and needs to be fixed.
if not is_relative and len(module_components) > 1:
import_dirs = module_components
for i in range(len(import_dirs)):
@@ -150,7 +153,8 @@ def scan(node, env, path=()):
if node:
nodes.append(node)
- return sorted(nodes)
+ print('returning nodes %s' % ([str(n) for n in nodes]))
+ return nodes
PythonSuffixes = ['.py']
diff --git a/test/Scanner/Python.py b/test/Scanner/Python.py
index 404967c..bb6e2c7 100644
--- a/test/Scanner/Python.py
+++ b/test/Scanner/Python.py
@@ -32,7 +32,7 @@ import TestSCons
test = TestSCons.TestSCons()
test.dir_fixture('Python')
-test.run(arguments = '-n --tree=prune --debug=stacktrace .', stdout='')
+test.run(arguments = '--debug=stacktrace .', stdout='')
test.pass_test()
# Local Variables: