From d924320853dda76c7940451a385c26c73c46d1f6 Mon Sep 17 00:00:00 2001 From: Eric Ayers Date: Thu, 16 Oct 2025 12:09:57 -0400 Subject: [PATCH] Adds the description from pyproject.toml to bundle Adds the description field from the pypi pyproject.toml metadata to the bundle's json description for each library. If the description is not present, the field will be populated with the empty string. --- README.md | 2 +- circuitpython_build_tools/build.py | 19 ++++++++++--------- .../scripts/build_bundles.py | 6 ++++-- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 5b85c43..7f2aadb 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ cd circuitpython-build-tools # this will be specific to your storage location python3 -m venv .env source .env/bin/activate pip install -e . # '-e' is pip's "development" install feature -circuitpython-build-bundles --filename_prefix --library_location +circuitpython-build-bundles --filename_prefix --library_location --library_depth 2 ``` ## Contributing diff --git a/circuitpython_build_tools/build.py b/circuitpython_build_tools/build.py index ab28b72..1cd5137 100644 --- a/circuitpython_build_tools/build.py +++ b/circuitpython_build_tools/build.py @@ -41,19 +41,19 @@ import platformdirs @functools.cache -def _git_version(): - version_str = subprocess.check_output(["git", "--version"], encoding="ascii", errors="replace") +def _git_version(): + version_str = subprocess.check_output(["git", "--version"], encoding="ascii", errors="replace") version_str = re.search("([0-9]\.*)*[0-9]", version_str).group(0) return tuple(int(part) for part in version_str.split(".")) - + def git_filter_arg(): - clone_supports_filter = ( + clone_supports_filter = ( False if "NO_USE_CLONE_FILTER" in os.environ else _git_version() >= (2, 36, 0) - ) - - if clone_supports_filter: + ) + + if clone_supports_filter: return ["--filter=blob:none"] - else: + else: return [] # pyproject.toml `py_modules` values that are incorrect. These should all have PRs filed! @@ -123,7 +123,7 @@ def mpy_cross(version, quiet=False): name = version["name"] ext = ".exe" * (os.name == "nt") mpy_cross_filename = mpy_cross_path / f"mpy-cross-{name}{ext}" - + if os.path.isfile(mpy_cross_filename): return mpy_cross_filename @@ -205,6 +205,7 @@ def get_package_info(library_path, package_folder_prefix): pyproject_toml = load_pyproject_toml(lib_path) py_modules = get_nested(pyproject_toml, "tool", "setuptools", "py-modules", default=[]) packages = get_nested(pyproject_toml, "tool", "setuptools", "packages", default=[]) + package_info["description"] = get_nested(pyproject_toml, "project", "description", default="") blocklisted = [name for name in py_modules if name in pyproject_py_modules_blocklist] diff --git a/circuitpython_build_tools/scripts/build_bundles.py b/circuitpython_build_tools/scripts/build_bundles.py index c7fad1e..56c285f 100755 --- a/circuitpython_build_tools/scripts/build_bundles.py +++ b/circuitpython_build_tools/scripts/build_bundles.py @@ -86,10 +86,10 @@ def get_bundle_requirements(directory, package_list): Remove anything that shouldn't be a requirement like Adafruit_Blinka Return the list """ - + pypi_reqs = set() # For multiple bundle dependency dependencies = set() # For intra-bundle dependency - + path = directory + "/requirements.txt" if os.path.exists(path): with open(path, "r") as file: @@ -133,6 +133,7 @@ def build_bundle_json(libs, bundle_version, output_filename, package_folder_pref package["version"] = package_info["version"] package["path"] = "lib/" + package_info["module_name"] package["library_path"] = library_path + package["pypi_description"] = package_info["description"] packages[module_name] = package library_submodules = {} @@ -144,6 +145,7 @@ def build_bundle_json(libs, bundle_version, output_filename, package_folder_pref library["repo"] = package["repo"] library["path"] = package["path"] library["dependencies"], library["external_dependencies"] = get_bundle_requirements(package["library_path"], packages) + library["pypi_description"] = package["pypi_description"] library_submodules[package["module_name"]] = library out_file = open(output_filename, "w")