pw_stm32cube_build: Pre-bootstrap support

Allows the pw_stm32cube_build tools to be used from a context where the
Python module has not yet been installed. This allows `gn gen` to
succeed on projects that set dir_pw_third_party_stm32cube in their .gn
file.

Bug: b/227780139
Change-Id: Ie080039bca1f22da1d0257032bf9d79cea8c4953
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/90061
Pigweed-Auto-Submit: Armando Montanez <amontanez@google.com>
Reviewed-by: Anthony DiGirolamo <tonymd@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
diff --git a/pw_stm32cube_build/py/pw_stm32cube_build/__main__.py b/pw_stm32cube_build/py/pw_stm32cube_build/__main__.py
index fff71ba..2170e34 100644
--- a/pw_stm32cube_build/py/pw_stm32cube_build/__main__.py
+++ b/pw_stm32cube_build/py/pw_stm32cube_build/__main__.py
@@ -18,7 +18,15 @@
 import pathlib
 import sys
 
-from pw_stm32cube_build import find_files, gen_file_list, icf_to_ld, inject_init
+try:
+    from pw_stm32cube_build import (find_files, gen_file_list, icf_to_ld,
+                                    inject_init)
+except ImportError:
+    # Load from this directory if pw_stm32cube_build is not available.
+    import find_files  # type: ignore
+    import gen_file_list  # type: ignore
+    import icf_to_ld  # type: ignore
+    import inject_init  # type: ignore
 
 
 def _parse_args() -> argparse.Namespace: