Skip to content

Commit 9456732

Browse files
committed
unix: Include upip as fronzen modules inside the standard interpreter.
MicroPython doesn't come with standard library included, so it is important to be able to easily install needed package in a seamless manner. Bundling package manager (upip) inside an executable solves this issue. upip is bundled only with standard executable, not "minimal" or "fast" builds.
1 parent 2fc1e64 commit 9456732

4 files changed

Lines changed: 28 additions & 0 deletions

File tree

unix/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ micropython
55
micropython_fast
66
micropython_minimal
77
*.py
8+
micropython-upip-*

unix/Makefile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,13 @@ SRC_C = \
103103
coverage.c \
104104
$(SRC_MOD)
105105

106+
# Include builtin package manager in the standard build (and coverage)
107+
ifeq ($(PROG),micropython)
108+
SRC_C += $(BUILD)/_frozen_upip.c
109+
else ifeq ($(PROG),micropython_coverage)
110+
SRC_C += $(BUILD)/_frozen_upip.c
111+
endif
112+
106113
LIB_SRC_C = $(addprefix lib/,\
107114
$(LIB_SRC_C_EXTRA) \
108115
)
@@ -153,3 +160,17 @@ coverage_test: coverage
153160
cd ../tests && MICROPY_MICROPYTHON=../$(DIRNAME)/micropython_coverage ./run-tests --emit native
154161
gcov -o build-coverage/py ../py/*.c
155162
gcov -o build-coverage/extmod ../extmod/*.c
163+
164+
$(BUILD)/_frozen_upip.c: frozen_upip/upip.py
165+
../tools/make-frozen.py frozen_upip > $@
166+
167+
# Select latest upip version available
168+
UPIP_TARBALL := $(shell ls -1 -v ../tools/micropython-upip-*.tar.gz | tail -n1)
169+
170+
frozen_upip/upip.py: $(UPIP_TARBALL)
171+
$(Q)rm -rf micropython-upip-*
172+
$(ECHO) "MISC Preparing upip as frozen module"
173+
$(Q)tar xfz $^
174+
$(Q)rm -rf frozen_upip
175+
$(Q)mkdir -p frozen_upip
176+
$(Q)cp micropython-upip-*/upip*.py frozen_upip/

unix/mpconfigport.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
#define MICROPY_PY_CMATH (1)
8282
#define MICROPY_PY_IO_FILEIO (1)
8383
#define MICROPY_PY_GC_COLLECT_RETVAL (1)
84+
#define MICROPY_MODULE_FROZEN (1)
8485

8586
#define MICROPY_STACKLESS (0)
8687
#define MICROPY_STACKLESS_STRICT (0)

unix/mpconfigport_fast.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,8 @@
3333
// 91 is a magic number proposed by @dpgeorge, which make pystone run ~ at tie
3434
// with CPython 3.4.
3535
#define MICROPY_MODULE_DICT_SIZE (91)
36+
37+
// Don't include builtin upip, as this build is again intended just for
38+
// synthetic benchmarking
39+
#undef MICROPY_MODULE_FROZEN
40+
#define MICROPY_MODULE_FROZEN (0)

0 commit comments

Comments
 (0)