diff options
author | 2017-10-16 16:22:27 +0200 | |
---|---|---|
committer | 2017-10-16 17:49:10 +0200 | |
commit | a975b1356ad9b279a93080c72a064ec30f928790 (patch) | |
tree | 9127e0ffc0c31031ce7675c5dad265bc4824b072 /src/main | |
parent | a97f914e5be7c10f44c7573ac41b1c4f0377136d (diff) |
Clean up FindModuleSpace.
- Delete "infinite" loop that always ran once.
- Remove erroneous comment about resolving symlinks. This hasn't been
true since 58ee85afcab07374dabc5493c780cbe3369b644f ("Don't follow
symlink when looking for python module space")
Change-Id: Ibfaddc3aa2b3f89b180c74f86796c0d39f4092d3
PiperOrigin-RevId: 172321824
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/bazel/rules/python/python_stub_template.txt | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/python/python_stub_template.txt b/src/main/java/com/google/devtools/build/lib/bazel/rules/python/python_stub_template.txt index 2aacd411e6..6adf21f01d 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/python/python_stub_template.txt +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/python/python_stub_template.txt @@ -71,25 +71,19 @@ def CreatePythonPathEntries(python_imports, module_space): # Find the runfiles tree def FindModuleSpace(): - # Follow symlinks, looking for my module space stub_filename = os.path.abspath(sys.argv[0]) - while True: - # Found it? - module_space = stub_filename + '.runfiles' - if os.path.isdir(module_space): - break - - runfiles_pattern = "(.*\.runfiles)/.*" - if IsWindows(): - runfiles_pattern = "(.*\.runfiles)\\.*" - matchobj = re.match(runfiles_pattern, os.path.abspath(sys.argv[0])) - if matchobj: - module_space = matchobj.group(1) - break - - raise AssertionError('Cannot find .runfiles directory for %s' % - sys.argv[0]) - return module_space + module_space = stub_filename + '.runfiles' + if os.path.isdir(module_space): + return module_space + + runfiles_pattern = "(.*\.runfiles)/.*" + if IsWindows(): + runfiles_pattern = "(.*\.runfiles)\\.*" + matchobj = re.match(runfiles_pattern, os.path.abspath(sys.argv[0])) + if matchobj: + return matchobj.group(1) + + raise AssertionError('Cannot find .runfiles directory for %s' % sys.argv[0]) # Create the runfiles tree by extracting the zip file def CreateModuleSpace(): |