aboutsummaryrefslogtreecommitdiff
path: root/pw_build
diff options
context:
space:
mode:
authorAnthony DiGirolamo <tonymd@google.com>2022-06-10 14:20:58 -0700
committerCQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-06-15 23:01:45 +0000
commit3f0dc0a09235b49d2e7fdfbca99e644ff2b2fd4b (patch)
tree6dbc798b0a3bec799e472343bf25a8d526b04f60 /pw_build
parent4331b174c459809439130c84bf12a26d78df7180 (diff)
downloadpigweed-3f0dc0a09235b49d2e7fdfbca99e644ff2b2fd4b.tar.gz
pw_build: Fine tune python_runner's PYTHONPATH logic
If no __init__.py exists for a given python_dep, don't add it to the PYTHONPATH. Bug: b/235615763 Change-Id: Idb18114ca48d39bfbfe9d0f110accb3f82cdc0b4 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/97790 Commit-Queue: Anthony DiGirolamo <tonymd@google.com> Reviewed-by: Armando Montanez <amontanez@google.com>
Diffstat (limited to 'pw_build')
-rwxr-xr-xpw_build/py/pw_build/python_runner.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/pw_build/py/pw_build/python_runner.py b/pw_build/py/pw_build/python_runner.py
index 451b82291..82a9b8087 100755
--- a/pw_build/py/pw_build/python_runner.py
+++ b/pw_build/py/pw_build/python_runner.py
@@ -565,7 +565,12 @@ def main( # pylint: disable=too-many-arguments,too-many-branches,too-many-local
raise MissingPythonDependency(
'Unable to find top level source dir for the Python '
f'package "{pkg}"')
+ # Don't add this dir to the PYTHONPATH if no __init__.py exists.
+ init_py_files = top_level_source_dir.parent.glob('*/__init__.py')
+ if not any(init_py_files):
+ continue
python_paths_list.append(top_level_source_dir.parent.resolve())
+
# Sort the PYTHONPATH list, it will be in a different order each build.
python_paths_list = sorted(python_paths_list)