From c84c30846cded89bfef889ae3bd92f9102fab816 Mon Sep 17 00:00:00 2001 From: sommersoft Date: Mon, 29 Jun 2020 09:02:04 -0500 Subject: [PATCH] docs/shared_bindings_matrix.py: use '__file__' to ascertain root dir --- docs/shared_bindings_matrix.py | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/docs/shared_bindings_matrix.py b/docs/shared_bindings_matrix.py index 12a7b7eb86..4abf5b8859 100644 --- a/docs/shared_bindings_matrix.py +++ b/docs/shared_bindings_matrix.py @@ -34,22 +34,10 @@ SUPPORTED_PORTS = ['atmel-samd', 'esp32s2', 'litex', 'mimxrt10xx', 'nrf', 'stm'] def get_circuitpython_root_dir(): """ The path to the root './circuitpython' directory """ - cwd = pathlib.Path('.').resolve() - cwd_parts = cwd.parts + file_path = pathlib.Path(__file__).resolve() + root_dir = file_path.parent.parent - root_idx = len(cwd_parts) - - # Search the path from tail to head, so that we capture the - # deepest folder. This avoids overshooting in instances like: - # '/home/user/circuitpython_v5/circuitpython' - for idx, val in enumerate(cwd_parts[::-1]): - if val.startswith("circuitpython"): - root_idx = root_idx - idx - break - - root_dir = '/'.join(cwd_parts[:root_idx]) - - return pathlib.Path(root_dir).resolve() + return root_dir def get_shared_bindings(): """ Get a list of modules in shared-bindings based on folder names