0
0
mirror of https://github.com/openwrt/packages.git synced 2025-02-07 09:19:51 +00:00
Jeffery To 9390bd0262 micropython-lib: Update to master, split target package
The package has been reworked to install the same files that are
available to be downloaded/installed by mip, the package manager new to
MicroPython 1.20.0.

This also splits the original target package into four:

* micropython-lib
  * Includes packages common to all MicroPython ports (python-stdlib,
    python-ecosys, micropython)
  * Contains mpy bytecode files

* micropython-lib-src
  * Includes packages common to all MicroPython ports (python-stdlib,
    python-ecosys, micropython)
  * Contains py source files

* micropython-lib-unix
  * Includes packages specific to the MicroPython Unix port (unix-ffi)
  * Contains mpy bytecode files
  * Installs a specific launcher (micropython-unix) that adds the Unix
    package directory into MicroPython's library path

* micropython-lib-unix-src
  * Includes packages specific to the MicroPython Unix port (unix-ffi)
  * Contains py source files

This also updates the package license, title, and description.

Patches:

* 001-build-unix-ffi.patch

  This enables the repo build script to also build the Unix-specific
  packages. Not sure if upstream is open to accepting this since the
  Unix-specific packages don't fit well into the existing package
  distribution mechanism.

* 002-add-unix-ffi-os-path.patch and 003-add-unix-ffi-uu.patch

  These fix instances where the unix-ffi version of the os package is
  overridden by the python-stdlib version. These have been submitted to
  upstream: https://github.com/micropython/micropython-lib/pull/672

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
2023-06-02 21:39:58 +08:00

63 lines
2.0 KiB
Python

#!/usr/bin/env python3
#
# Copyright (C) 2023 Jeffery To
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
import json
import os
import re
import shutil
import sys
def install(input_path, mpy_version, output_path):
index_json_path = os.path.join(input_path, "index.json")
files = {}
with open(index_json_path) as f:
index_json = json.load(f)
for p in index_json["packages"]:
package_name = p["name"]
package_json_path = os.path.join(input_path, "package", mpy_version, package_name, "latest.json")
with open(package_json_path) as f:
package_json = json.load(f)
for file_name, file_hash in package_json["hashes"]:
if file_name in files:
if file_hash != files[file_name]:
print("File name/hash collision:", package_name, file=sys.stderr)
print(" File: ", file_name, file=sys.stderr)
print(" Curent hash: ", file_hash, file=sys.stderr)
print(" Previous hash: ", files[file_name], file=sys.stderr)
sys.exit(1)
else:
files[file_name] = file_hash
for file_name, file_hash in files.items():
in_file_path = os.path.join(input_path, "file", file_hash[:2], file_hash)
out_file_path = os.path.join(output_path, file_name)
os.makedirs(os.path.dirname(out_file_path), exist_ok=True)
shutil.copy2(in_file_path, out_file_path)
def main():
import argparse
cmd_parser = argparse.ArgumentParser(description="Install compiled micropython-lib packages.")
cmd_parser.add_argument("--input", required=True, help="input directory")
cmd_parser.add_argument("--version", required=True, help="mpy version to install")
cmd_parser.add_argument("--output", required=True, help="output directory")
args = cmd_parser.parse_args()
install(args.input, args.version, args.output)
if __name__ == "__main__":
main()