Files
buildroot/package/micropython/collect_micropython_lib.py
Daniel Houck 28eeca9a98 package/micropython: bump to version 1.28.0
This allows us to fix packaging issue with micropython-lib, which was
not packaging the correct versions of some libraries.  The new version
makes changes to the `manifestfile` tool/library used by our
collect_micropython_libs.py script, which makes it easier to collect the
correct library version.  This fixes #166.

To better support alternate use cases, the option to package the modules
in unix-ffi has been split into a separate option, instead of assuming
it's needed if and only if libffi is selected.

Both the upstream changes and the unix-ffi split require changes to
collect_micropython_libs.py.  First, since we might not want the
unix-ffi libraries, the script takes an extra argument for whether or
not to include them.  Next, since the manifest.require function no
longer takes a unix_ffi optional parameter, we use manifest.add_library
as recommended in the micropython-lib/unix-ffi directory README, if we
are are actually packaging those libraries.

All of the patches we have been maintaining have also been merged upstream
by 1.28.0, so they are removed.  Their respective Upstream: trailers all
point to the relevant commits, except for
0003-Fixes-for-GCC-15-1-unterminated-string-literal-warning.patch, from
ae6062a45a

The LICENSE hash has been updated, as the year and the licenses used for
the ports and libraries have also been updated in the LICENSE file.

For more details on the version bump, see the release notes:
  - https://github.com/micropython/micropython/releases/tag/v1.23.0
  - https://github.com/micropython/micropython/releases/tag/v1.24.0
  - https://github.com/micropython/micropython/releases/tag/v1.24.1
  - https://github.com/micropython/micropython/releases/tag/v1.25.0
  - https://github.com/micropython/micropython/releases/tag/v1.26.0
  - https://github.com/micropython/micropython/releases/tag/v1.26.1
  - https://github.com/micropython/micropython/releases/tag/v1.27.0
  - https://github.com/micropython/micropython/releases/tag/v1.28.0

Signed-off-by: Daniel Houck <Software@DRHouck.me>
Signed-off-by: Julien Olivain <ju.o@free.fr>
2026-06-12 18:55:30 +02:00

86 lines
2.5 KiB
Python
Executable File

#!/usr/bin/env python3
"""
Sometime after v1.9.3, micropython-lib's directory structure was cleaned up and
enhanced with manifest files.
Though cleaner, it means it cannot be directly copied into the target.
This script is during build process to perform that conversion.
It makes use of manifestfile.py, which is normally located in micropython's
tool directory.
It also depends on the micropython-lib that is cloned in lib/micropython-lib
during build.
"""
import argparse
import manifestfile
import os
import shutil
def get_library_name_type(manifest_path: str) -> tuple[str, bool]:
split = manifest_path.split("/")
return (split[-2], "unix-ffi" in split) # -1: "manifest.py", -2: library name
def get_all_libraries(mpy_lib_dir: str):
# reuse manifestfile module capabilities to scan the micropython-lib directory
collected_list = manifestfile.ManifestFile(
manifestfile.MODE_FREEZE, {"MPY_LIB_DIR": mpy_lib_dir}
)
collected_list.freeze(mpy_lib_dir)
for file in collected_list.files():
if file.target_path.endswith("manifest.py"):
yield get_library_name_type(file.full_path)
def copy_file(src: str, target: str, destination: str):
s = target.split("/")
s.pop()
d = f"{destination}/{'/'.join(s)}"
os.makedirs(d, exist_ok=True)
shutil.copy(src, f"{destination}/{target}")
def copy_libraries(manifest, destination: str):
for f in manifest.files():
copy_file(f.full_path, f.target_path, destination)
def process_cmdline_args():
parser = argparse.ArgumentParser(
description="Prepare micropython-lib to be installed"
)
parser.add_argument("micropython", help="Path to micropython source directory")
parser.add_argument("destination", help="Destination directory")
parser.add_argument("--ffi", action=argparse.BooleanOptionalAction,
default=True, help="Install libs that require FFI")
args = parser.parse_args()
return args
def main():
args = process_cmdline_args()
mpy_lib_dir = f"{args.micropython}/lib/micropython-lib"
manifest = manifestfile.ManifestFile(
manifestfile.MODE_FREEZE, {"MPY_LIB_DIR": mpy_lib_dir}
)
if args.ffi:
manifest.add_library("unix-ffi", os.path.join("$(MPY_LIB_DIR)", "unix-ffi"),
prepend=True)
for library, is_ffi in get_all_libraries(mpy_lib_dir):
if args.ffi or not is_ffi:
manifest.require(library)
copy_libraries(manifest, args.destination)
main()