From 197a5724d866f1f3389c9f96e7263d24955b942d Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sat, 22 Oct 2016 21:14:58 +0300 Subject: tools: Upgrade upip to 1.1.4. Fix error on unix when installing to non-existing absolute path. --- tools/micropython-upip-1.1.3.tar.gz | Bin 4072 -> 0 bytes tools/micropython-upip-1.1.4.tar.gz | Bin 0 -> 4090 bytes 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 tools/micropython-upip-1.1.3.tar.gz create mode 100644 tools/micropython-upip-1.1.4.tar.gz (limited to 'tools') diff --git a/tools/micropython-upip-1.1.3.tar.gz b/tools/micropython-upip-1.1.3.tar.gz deleted file mode 100644 index 90f726d86..000000000 Binary files a/tools/micropython-upip-1.1.3.tar.gz and /dev/null differ diff --git a/tools/micropython-upip-1.1.4.tar.gz b/tools/micropython-upip-1.1.4.tar.gz new file mode 100644 index 000000000..588fc4d62 Binary files /dev/null and b/tools/micropython-upip-1.1.4.tar.gz differ -- cgit v1.2.3 From 06e703290640ed6326bf70e172c25be92799591f Mon Sep 17 00:00:00 2001 From: Alex March Date: Wed, 19 Oct 2016 09:32:49 +0100 Subject: qemu-arm: Exclude extmod/vfs_fat_fileio.py test. --- tools/tinytest-codegen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/tinytest-codegen.py b/tools/tinytest-codegen.py index bab937135..4559b06e9 100755 --- a/tools/tinytest-codegen.py +++ b/tools/tinytest-codegen.py @@ -53,7 +53,7 @@ exclude_tests = ( 'extmod/ujson_dumps_float.py', 'extmod/ujson_loads_float.py', 'extmod/uctypes_native_float.py', 'extmod/uctypes_le_float.py', 'extmod/machine_pinbase.py', 'extmod/machine_pulse.py', - 'extmod/vfs_fat_ramdisk.py', + 'extmod/vfs_fat_ramdisk.py', 'extmod/vfs_fat_fileio.py', ) output = [] -- cgit v1.2.3 From b78144c64d71e8b850a0fd7051bcaa9ee0cce8dd Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Mon, 24 Oct 2016 16:50:58 +0300 Subject: tools/pip-micropython: Remove deprecated wrapper tool. Deprecated for long time, pip-micropython now can't install packages optimized for low-heap ports (like whole of micropython-lib). --- tools/pip-micropython | 93 --------------------------------------------------- 1 file changed, 93 deletions(-) delete mode 100755 tools/pip-micropython (limited to 'tools') diff --git a/tools/pip-micropython b/tools/pip-micropython deleted file mode 100755 index c7b23f1b6..000000000 --- a/tools/pip-micropython +++ /dev/null @@ -1,93 +0,0 @@ -#!/bin/sh -# -# This tool can be used to install a new package into MicroPython -# library location (for unix port, default behavior), or produce -# complete library snapshot to be deployed on a device for baremetal -# ports (if PIP_MICROPY_DEST environment var is set). -# -# Note: this tool is deprecated in favor of "upip" native MicroPython -# package manager, which is bundled with MicroPython unix binary -# as a frozen module and can be run as "micropython -u pip" or installed -# from PyPI package "micropython-upip". This utility is left for -# reference, regression testing, debugging, etc. -# - -if [ "$1" != "install" ]; then - echo "Only install command is supported currently" - exit 1 -fi -shift - -if [ -z "$TMPDIR" ]; then - TMPDIR=/tmp -fi -TMPVENV="$TMPDIR/pip-micropy-venv" - -if [ -n "$PIP_MICROPY_DEST" ]; then - dest="$PIP_MICROPY_DEST" - echo "Destination snapshot directory: $dest" -elif [ -n "$MICROPYPATH" ]; then - libdest=$(echo "$MICROPYPATH" | awk -F: ' {print $1}') - echo "Destination library directory: $libdest" -else - echo "Warning: MICROPYPATH is not set, assuming default value" - libdest=~/.micropython/lib - echo "Destination library directory: $libdest" -fi - -# Due to bugs in pip, installation should happen with active virtualenv -# The issue (at least with pip 1.0 which is still what's shipped with many -# distros) is that even if --ignore-installed is used, package is not -# installed if it's already installed for main python distribution. -if [ ! -d "$TMPVENV" ]; then - virtualenv --no-site-packages "$TMPVENV" - # distutils, setuptools, pip are buggy and allow target packages affect - # their execution environment. For example, if distribution they install - # has re.py, they will import that instead of system re. So, we need - # to remove current dir from sys.path, but that appear to be quite uneasy - # with CPython, so we hook __import__ and exterminate it persistently. - # See also https://bitbucket.org/pypa/setuptools/issue/187/ - cat > $(ls -1d "$TMPVENV"/lib/python*/)/sitecustomize.py < Date: Tue, 25 Oct 2016 11:07:29 +0300 Subject: tools/check_code_size.sh: Code size validation script for CI. --- tools/check_code_size.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 tools/check_code_size.sh (limited to 'tools') diff --git a/tools/check_code_size.sh b/tools/check_code_size.sh new file mode 100755 index 000000000..c5f0c6ffd --- /dev/null +++ b/tools/check_code_size.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# +# This script check that changes don't lead to code size regressions. +# (Size of the language core (== minimal port should not grow)). +# + +REFERENCE=$HOME/persist/firmware.bin +#REFERENCE=/tmp/micropython +#TRAVIS_PULL_REQUEST=false + +if [ -f $REFERENCE ]; then + size_old=$(stat -c%s $REFERENCE) + size_new=$(stat -c%s minimal/build/firmware.bin) + echo "Old size: $size_old new size: $size_new" + if [ $size_new -gt $size_old ]; then + echo "Validation failure: Core code size increased" + if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then + exit 1 + fi + fi +else + echo "Warning: reference file doesn't exist, code size check didn't run" +fi -- cgit v1.2.3 From 52aa532050baa4239e1920144ecf1d0588fc672e Mon Sep 17 00:00:00 2001 From: Alex March Date: Fri, 21 Oct 2016 10:45:09 +0100 Subject: qemu-arm: Exclude new vfs_fat tests. --- tools/tinytest-codegen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/tinytest-codegen.py b/tools/tinytest-codegen.py index 4559b06e9..271eb55a3 100755 --- a/tools/tinytest-codegen.py +++ b/tools/tinytest-codegen.py @@ -53,7 +53,7 @@ exclude_tests = ( 'extmod/ujson_dumps_float.py', 'extmod/ujson_loads_float.py', 'extmod/uctypes_native_float.py', 'extmod/uctypes_le_float.py', 'extmod/machine_pinbase.py', 'extmod/machine_pulse.py', - 'extmod/vfs_fat_ramdisk.py', 'extmod/vfs_fat_fileio.py', + 'extmod/vfs_fat_ramdisk.py', 'extmod/vfs_fat_fileio.py', 'extmod/vfs_fat_fsusermount.py', 'extmod/vfs_fat_oldproto.py', ) output = [] -- cgit v1.2.3 From 796b720dbcc73374418de571699de99de4edaf41 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sun, 30 Oct 2016 22:24:07 +0300 Subject: tools/tinytest-codegen: Exclude ticks_diff test for qemu-arm port. --- tools/tinytest-codegen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/tinytest-codegen.py b/tools/tinytest-codegen.py index 271eb55a3..c4198832a 100755 --- a/tools/tinytest-codegen.py +++ b/tools/tinytest-codegen.py @@ -49,7 +49,7 @@ testgroup_member = ( test_dirs = ('basics', 'micropython', 'extmod', 'inlineasm') # 'float', 'import', 'io', 'misc') exclude_tests = ( 'inlineasm/asmfpaddsub.py', 'inlineasm/asmfpcmp.py', 'inlineasm/asmfpldrstr.py', 'inlineasm/asmfpmuldiv.py', 'inlineasm/asmfpsqrt.py', - 'extmod/time_ms_us.py', + 'extmod/ticks_diff.py', 'extmod/time_ms_us.py', 'extmod/ujson_dumps_float.py', 'extmod/ujson_loads_float.py', 'extmod/uctypes_native_float.py', 'extmod/uctypes_le_float.py', 'extmod/machine_pinbase.py', 'extmod/machine_pulse.py', -- cgit v1.2.3 From ca973bd3083492777095a07c20965a4644899ec9 Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 3 Nov 2016 12:28:31 +1100 Subject: qemu-arm: Enable software floating point support, and float tests. This helps to test floating point code on Cortex-M hardware. As part of this patch the link-time-optimisation was disabled because it wasn't compatible with software FP support. In particular, the linker could not find the __aeabi_f2d, __aeabi_d2f etc functions even though they were provided by lib/libm/math.c. --- qemu-arm/Makefile | 27 +++++++++++++++++++++++++-- qemu-arm/mpconfigport.h | 2 +- tools/tinytest-codegen.py | 5 ++--- 3 files changed, 28 insertions(+), 6 deletions(-) (limited to 'tools') diff --git a/qemu-arm/Makefile b/qemu-arm/Makefile index 9159f97e5..0af2fc901 100644 --- a/qemu-arm/Makefile +++ b/qemu-arm/Makefile @@ -14,9 +14,9 @@ INC += -I.. INC += -I$(BUILD) INC += -I../tools/tinytest/ -CFLAGS_CORTEX_M3 = -mthumb -mcpu=cortex-m3 +CFLAGS_CORTEX_M3 = -mthumb -mcpu=cortex-m3 -mfloat-abi=soft CFLAGS = $(INC) -Wall -Wpointer-arith -Werror -ansi -std=gnu99 $(CFLAGS_CORTEX_M3) $(COPT) \ - -flto -ffunction-sections -fdata-sections + -ffunction-sections -fdata-sections #Debugging/Optimization ifeq ($(DEBUG), 1) @@ -40,6 +40,27 @@ SRC_C = \ SRC_TEST_C = \ test_main.c \ +LIB_SRC_C = $(addprefix lib/,\ + libm/math.c \ + libm/fmodf.c \ + libm/roundf.c \ + libm/ef_sqrt.c \ + libm/kf_rem_pio2.c \ + libm/kf_sin.c \ + libm/kf_cos.c \ + libm/kf_tan.c \ + libm/ef_rem_pio2.c \ + libm/sf_sin.c \ + libm/sf_cos.c \ + libm/sf_tan.c \ + libm/sf_frexp.c \ + libm/sf_modf.c \ + libm/sf_ldexp.c \ + libm/asinfacosf.c \ + libm/atanf.c \ + libm/atan2f.c \ + ) + STM_SRC_C = $(addprefix stmhal/,\ pybstdio.c \ ) @@ -50,12 +71,14 @@ OBJ = OBJ += $(PY_O) OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o)) OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o)) +OBJ += $(addprefix $(BUILD)/, $(LIB_SRC_C:.c=.o)) OBJ += $(addprefix $(BUILD)/, $(STM_SRC_C:.c=.o)) OBJ_TEST = OBJ_TEST += $(PY_O) OBJ_TEST += $(addprefix $(BUILD)/, $(SRC_TEST_C:.c=.o)) OBJ_TEST += $(addprefix $(BUILD)/, $(SRC_S:.s=.o)) +OBJ_TEST += $(addprefix $(BUILD)/, $(LIB_SRC_C:.c=.o)) OBJ_TEST += $(addprefix $(BUILD)/, $(STM_SRC_C:.c=.o)) OBJ_TEST += $(BUILD)/tinytest.o diff --git a/qemu-arm/mpconfigport.h b/qemu-arm/mpconfigport.h index 2b8ae855a..8ee9cdc4b 100644 --- a/qemu-arm/mpconfigport.h +++ b/qemu-arm/mpconfigport.h @@ -14,7 +14,7 @@ #define MICROPY_HELPER_LEXER_UNIX (0) #define MICROPY_ENABLE_SOURCE_LINE (1) #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ) -#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE) +#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT) #define MICROPY_CAN_OVERRIDE_BUILTINS (1) #define MICROPY_PY_ALL_SPECIAL_METHODS (1) #define MICROPY_PY_ARRAY_SLICE_ASSIGN (1) diff --git a/tools/tinytest-codegen.py b/tools/tinytest-codegen.py index c4198832a..8e505f21a 100755 --- a/tools/tinytest-codegen.py +++ b/tools/tinytest-codegen.py @@ -46,12 +46,11 @@ testgroup_member = ( ## XXX: may be we could have `--without ` argument... # currently these tests are selected because they pass on qemu-arm -test_dirs = ('basics', 'micropython', 'extmod', 'inlineasm') # 'float', 'import', 'io', 'misc') +test_dirs = ('basics', 'micropython', 'float', 'extmod', 'inlineasm') # 'import', 'io', 'misc') exclude_tests = ( + 'float/float2int_doubleprec.py', # requires double precision floating point to work 'inlineasm/asmfpaddsub.py', 'inlineasm/asmfpcmp.py', 'inlineasm/asmfpldrstr.py', 'inlineasm/asmfpmuldiv.py', 'inlineasm/asmfpsqrt.py', 'extmod/ticks_diff.py', 'extmod/time_ms_us.py', - 'extmod/ujson_dumps_float.py', 'extmod/ujson_loads_float.py', - 'extmod/uctypes_native_float.py', 'extmod/uctypes_le_float.py', 'extmod/machine_pinbase.py', 'extmod/machine_pulse.py', 'extmod/vfs_fat_ramdisk.py', 'extmod/vfs_fat_fileio.py', 'extmod/vfs_fat_fsusermount.py', 'extmod/vfs_fat_oldproto.py', ) -- cgit v1.2.3 From 61d74fdef836753cbf1cf0e9ee7b8e50cb80f41d Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Mon, 7 Nov 2016 18:13:56 +0300 Subject: tools, unix: Replace upip tarball with just source files. To make its inclusion as frozen modules in multiple ports less magic. Ports are just expected to symlink 2 files into their scripts/modules subdirs. Unix port updated to use this and in general follow frozen modules setup tested and tried on baremetal ports, where there's "scripts" predefined dir (overridable with FROZEN_DIR make var), and a user just drops Python files there. --- tools/micropython-upip-1.1.4.tar.gz | Bin 4090 -> 0 bytes tools/upip.py | 288 ++++++++++++++++++++++++++++++++++++ tools/upip_utarfile.py | 94 ++++++++++++ unix/Makefile | 31 +--- 4 files changed, 385 insertions(+), 28 deletions(-) delete mode 100644 tools/micropython-upip-1.1.4.tar.gz create mode 100644 tools/upip.py create mode 100644 tools/upip_utarfile.py (limited to 'tools') diff --git a/tools/micropython-upip-1.1.4.tar.gz b/tools/micropython-upip-1.1.4.tar.gz deleted file mode 100644 index 588fc4d62..000000000 Binary files a/tools/micropython-upip-1.1.4.tar.gz and /dev/null differ diff --git a/tools/upip.py b/tools/upip.py new file mode 100644 index 000000000..db18a7427 --- /dev/null +++ b/tools/upip.py @@ -0,0 +1,288 @@ +import sys +import gc +import uos as os +import uerrno as errno +import ujson as json +import uzlib +import upip_utarfile as tarfile +gc.collect() + + +debug = False +install_path = None +cleanup_files = [] +gzdict_sz = 16 + 15 + +file_buf = bytearray(512) + +class NotFoundError(Exception): + pass + +def op_split(path): + if path == "": + return ("", "") + r = path.rsplit("/", 1) + if len(r) == 1: + return ("", path) + head = r[0] + if not head: + head = "/" + return (head, r[1]) + +def op_basename(path): + return op_split(path)[1] + +# Expects *file* name +def _makedirs(name, mode=0o777): + ret = False + s = "" + comps = name.rstrip("/").split("/")[:-1] + if comps[0] == "": + s = "/" + for c in comps: + if s and s[-1] != "/": + s += "/" + s += c + try: + os.mkdir(s) + ret = True + except OSError as e: + if e.args[0] != errno.EEXIST and e.args[0] != errno.EISDIR: + raise + ret = False + return ret + + +def save_file(fname, subf): + global file_buf + with open(fname, "wb") as outf: + while True: + sz = subf.readinto(file_buf) + if not sz: + break + outf.write(file_buf, sz) + +def install_tar(f, prefix): + meta = {} + for info in f: + #print(info) + fname = info.name + try: + fname = fname[fname.index("/") + 1:] + except ValueError: + fname = "" + + save = True + for p in ("setup.", "PKG-INFO", "README"): + #print(fname, p) + if fname.startswith(p) or ".egg-info" in fname: + if fname.endswith("/requires.txt"): + meta["deps"] = f.extractfile(info).read() + save = False + if debug: + print("Skipping", fname) + break + + if save: + outfname = prefix + fname + if info.type != tarfile.DIRTYPE: + if debug: + print("Extracting " + outfname) + _makedirs(outfname) + subf = f.extractfile(info) + save_file(outfname, subf) + return meta + +def expandhome(s): + if "~/" in s: + h = os.getenv("HOME") + s = s.replace("~/", h + "/") + return s + +import ussl +import usocket +warn_ussl = True +def url_open(url): + global warn_ussl + proto, _, host, urlpath = url.split('/', 3) + ai = usocket.getaddrinfo(host, 443) + #print("Address infos:", ai) + addr = ai[0][4] + + s = usocket.socket(ai[0][0]) + #print("Connect address:", addr) + s.connect(addr) + + if proto == "https:": + s = ussl.wrap_socket(s) + if warn_ussl: + print("Warning: %s SSL certificate is not validated" % host) + warn_ussl = False + + # MicroPython rawsocket module supports file interface directly + s.write("GET /%s HTTP/1.0\r\nHost: %s\r\n\r\n" % (urlpath, host)) + l = s.readline() + protover, status, msg = l.split(None, 2) + if status != b"200": + if status == b"404": + print("Package not found") + raise ValueError(status) + while 1: + l = s.readline() + if not l: + raise ValueError("Unexpected EOF") + if l == b'\r\n': + break + + return s + + +def get_pkg_metadata(name): + f = url_open("https://pypi.python.org/pypi/%s/json" % name) + s = f.read() + f.close() + return json.loads(s) + + +def fatal(msg): + print(msg) + sys.exit(1) + +def install_pkg(pkg_spec, install_path): + data = get_pkg_metadata(pkg_spec) + + latest_ver = data["info"]["version"] + packages = data["releases"][latest_ver] + del data + gc.collect() + assert len(packages) == 1 + package_url = packages[0]["url"] + print("Installing %s %s from %s" % (pkg_spec, latest_ver, package_url)) + package_fname = op_basename(package_url) + f1 = url_open(package_url) + f2 = uzlib.DecompIO(f1, gzdict_sz) + f3 = tarfile.TarFile(fileobj=f2) + meta = install_tar(f3, install_path) + f1.close() + del f3 + del f2 + gc.collect() + return meta + +def install(to_install, install_path=None): + # Calculate gzip dictionary size to use + global gzdict_sz + sz = gc.mem_free() + gc.mem_alloc() + if sz <= 65536: + gzdict_sz = 16 + 12 + + if install_path is None: + install_path = get_install_path() + if install_path[-1] != "/": + install_path += "/" + if not isinstance(to_install, list): + to_install = [to_install] + print("Installing to: " + install_path) + # sets would be perfect here, but don't depend on them + installed = [] + try: + while to_install: + if debug: + print("Queue:", to_install) + pkg_spec = to_install.pop(0) + if pkg_spec in installed: + continue + meta = install_pkg(pkg_spec, install_path) + installed.append(pkg_spec) + if debug: + print(meta) + deps = meta.get("deps", "").rstrip() + if deps: + deps = deps.decode("utf-8").split("\n") + to_install.extend(deps) + except NotFoundError: + print("Error: cannot find '%s' package (or server error), packages may be partially installed" \ + % pkg_spec, file=sys.stderr) + +def get_install_path(): + global install_path + if install_path is None: + # sys.path[0] is current module's path + install_path = sys.path[1] + install_path = expandhome(install_path) + return install_path + +def cleanup(): + for fname in cleanup_files: + try: + os.unlink(fname) + except OSError: + print("Warning: Cannot delete " + fname) + +def help(): + print("""\ +upip - Simple PyPI package manager for MicroPython +Usage: micropython -m upip install [-p ] ... | -r +import upip; upip.install(package_or_list, []) + +If is not given, packages will be installed into sys.path[1] +(can be set from MICROPYPATH environment variable, if current system +supports that).""") + print("Current value of sys.path[1]:", sys.path[1]) + print("""\ + +Note: only MicroPython packages (usually, named micropython-*) are supported +for installation, upip does not support arbitrary code in setup.py. +""") + +def main(): + global debug + global install_path + install_path = None + + if len(sys.argv) < 2 or sys.argv[1] == "-h" or sys.argv[1] == "--help": + help() + return + + if sys.argv[1] != "install": + fatal("Only 'install' command supported") + + to_install = [] + + i = 2 + while i < len(sys.argv) and sys.argv[i][0] == "-": + opt = sys.argv[i] + i += 1 + if opt == "-h" or opt == "--help": + help() + return + elif opt == "-p": + install_path = sys.argv[i] + i += 1 + elif opt == "-r": + list_file = sys.argv[i] + i += 1 + with open(list_file) as f: + while True: + l = f.readline() + if not l: + break + to_install.append(l.rstrip()) + elif opt == "--debug": + debug = True + else: + fatal("Unknown/unsupported option: " + opt) + + to_install.extend(sys.argv[i:]) + if not to_install: + help() + return + + install(to_install) + + if not debug: + cleanup() + + +if __name__ == "__main__": + main() diff --git a/tools/upip_utarfile.py b/tools/upip_utarfile.py new file mode 100644 index 000000000..65ce0bdca --- /dev/null +++ b/tools/upip_utarfile.py @@ -0,0 +1,94 @@ +import uctypes + +# http://www.gnu.org/software/tar/manual/html_node/Standard.html +TAR_HEADER = { + "name": (uctypes.ARRAY | 0, uctypes.UINT8 | 100), + "size": (uctypes.ARRAY | 124, uctypes.UINT8 | 12), +} + +DIRTYPE = "dir" +REGTYPE = "file" + +def roundup(val, align): + return (val + align - 1) & ~(align - 1) + +class FileSection: + + def __init__(self, f, content_len, aligned_len): + self.f = f + self.content_len = content_len + self.align = aligned_len - content_len + + def read(self, sz=65536): + if self.content_len == 0: + return b"" + if sz > self.content_len: + sz = self.content_len + data = self.f.read(sz) + sz = len(data) + self.content_len -= sz + return data + + def readinto(self, buf): + if self.content_len == 0: + return 0 + if len(buf) > self.content_len: + buf = memoryview(buf)[:self.content_len] + sz = self.f.readinto(buf) + self.content_len -= sz + return sz + + def skip(self): + sz = self.content_len + self.align + if sz: + buf = bytearray(16) + while sz: + s = min(sz, 16) + self.f.readinto(buf, s) + sz -= s + +class TarInfo: + + def __str__(self): + return "TarInfo(%r, %s, %d)" % (self.name, self.type, self.size) + +class TarFile: + + def __init__(self, name=None, fileobj=None): + if fileobj: + self.f = fileobj + else: + self.f = open(name, "rb") + self.subf = None + + def next(self): + if self.subf: + self.subf.skip() + buf = self.f.read(512) + if not buf: + return None + + h = uctypes.struct(uctypes.addressof(buf), TAR_HEADER, uctypes.LITTLE_ENDIAN) + + # Empty block means end of archive + if h.name[0] == 0: + return None + + d = TarInfo() + d.name = str(h.name, "utf-8").rstrip() + d.size = int(bytes(h.size).rstrip(), 8) + d.type = [REGTYPE, DIRTYPE][d.name[-1] == "/"] + self.subf = d.subf = FileSection(self.f, d.size, roundup(d.size, 512)) + return d + + def __iter__(self): + return self + + def __next__(self): + v = self.next() + if v is None: + raise StopIteration + return v + + def extractfile(self, tarinfo): + return tarinfo.subf diff --git a/unix/Makefile b/unix/Makefile index fd98d2ced..a14ed215c 100644 --- a/unix/Makefile +++ b/unix/Makefile @@ -1,6 +1,8 @@ -include mpconfigport.mk include ../py/mkenv.mk +FROZEN_DIR = scripts + # define main target PROG = micropython @@ -148,17 +150,6 @@ SRC_C = \ fatfs_port.c \ $(SRC_MOD) -# Include builtin package manager in the standard build (and coverage) -ifeq ($(PROG),micropython) -SRC_C += $(BUILD)/_frozen_upip.c -else ifeq ($(PROG),micropython_coverage) -SRC_C += $(BUILD)/_frozen_upip.c -else ifeq ($(PROG), micropython_nanbox) -SRC_C += $(BUILD)/_frozen_upip.c -else ifeq ($(PROG), micropython_freedos) -SRC_C += $(BUILD)/_frozen_upip.c -endif - LIB_SRC_C = $(addprefix lib/,\ $(LIB_SRC_C_EXTRA) \ timeutils/timeutils.c \ @@ -235,7 +226,7 @@ fast: # build a minimal interpreter minimal: $(MAKE) COPT="-Os -DNDEBUG" CFLAGS_EXTRA='-DMP_CONFIGFILE=""' \ - BUILD=build-minimal PROG=micropython_minimal \ + BUILD=build-minimal PROG=micropython_minimal FROZEN_DIR= \ MICROPY_PY_BTREE=0 MICROPY_PY_FFI=0 MICROPY_PY_SOCKET=0 MICROPY_PY_THREAD=0 \ MICROPY_PY_TERMIOS=0 MICROPY_PY_USSL=0 \ MICROPY_USE_READLINE=0 MICROPY_FATFS=0 @@ -272,22 +263,6 @@ coverage_test: coverage gcov -o build-coverage/py ../py/*.c gcov -o build-coverage/extmod ../extmod/*.c -$(BUILD)/_frozen_upip.c: $(BUILD)/frozen_upip/upip.py - $(MAKE_FROZEN) $(dir $^) > $@ - -# Select latest upip version available -UPIP_TARBALL := $(shell ls -1 -v ../tools/micropython-upip-*.tar.gz | tail -n1) - -$(BUILD)/frozen_upip/upip.py: $(UPIP_TARBALL) - $(ECHO) "MISC Preparing upip as frozen module" - $(Q)mkdir -p $(BUILD) - $(Q)rm -rf $(BUILD)/micropython-upip-* - $(Q)tar -C $(BUILD) -xz -f $^ - $(Q)rm -rf $(dir $@) - $(Q)mkdir -p $(dir $@) - $(Q)cp $(BUILD)/micropython-upip-*/upip*.py $(dir $@) - - # Value of configure's --host= option (required for cross-compilation). # Deduce it from CROSS_COMPILE by default, but can be overriden. ifneq ($(CROSS_COMPILE),) -- cgit v1.2.3