From dfc10c91a5e791c797fa29878e93ab283e65a48a Mon Sep 17 00:00:00 2001 From: Neradoc Date: Sun, 29 Dec 2024 18:59:23 +0100 Subject: [PATCH 1/2] avoid reading random strings (like IP addresses) as version numbers in mpy files always scan files in a package by alphabetical order so that `__init__` is read first then keep the first version number found, don't update it later --- circup/shared.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/circup/shared.py b/circup/shared.py index d3be33c..25a400c 100644 --- a/circup/shared.py +++ b/circup/shared.py @@ -79,14 +79,18 @@ def _get_modules_file(path, logger): py_files = glob.glob(os.path.join(package_path, "**/*.py"), recursive=True) mpy_files = glob.glob(os.path.join(package_path, "**/*.mpy"), recursive=True) all_files = py_files + mpy_files + # put __init__ first if any, assumed to have the version number + all_files.sort() # default value result[name] = {"path": package_path, "mpy": bool(mpy_files)} # explore all the submodules to detect bad ones for source in [f for f in all_files if not os.path.basename(f).startswith(".")]: metadata = extract_metadata(source, logger) if "__version__" in metadata: - metadata["path"] = package_path - result[name] = metadata + # don't replace metadata if already found + if "__version__" not in result[name]: + metadata["path"] = package_path + result[name] = metadata # break now if any of the submodules has a bad format if metadata["__version__"] == BAD_FILE_FORMAT: break From 1bc332b8394b3afde7c3b10ee970fb5016cf750c Mon Sep 17 00:00:00 2001 From: Neradoc Date: Sun, 29 Dec 2024 19:56:10 +0100 Subject: [PATCH 2/2] fix sphinx warning --- docs/conf.py | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 158bb5f..a3947ab 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -109,7 +109,6 @@ import sphinx_rtd_theme html_theme = "sphinx_rtd_theme" - html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."] except: html_theme = "default" html_theme_path = ["."]