[Buildroot] [PATCH 1/2] target-finalize: generate all *.pyc

Samuel Martin s.martin49 at gmail.com
Mon Mar 9 16:24:23 UTC 2015

This patch generates all *.pyc files from *.py located in
<target>/usr/python*/site-packages, before stripping the rootfs.

This prevents modules from packages that do not compile the *.py
files from disappearing.

Reported-by: Yegor Yefremov <yegorslists at googlemail.com>
Cc: Yegor Yefremov <yegorslists at googlemail.com>
Signed-off-by: Samuel Martin <s.martin49 at gmail.com>
 Makefile | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/Makefile b/Makefile
index af043a3..ec0b923 100644
--- a/Makefile
+++ b/Makefile
@@ -564,6 +564,11 @@ $(TARGETS_ROOTFS): target-finalize
 target-finalize: $(TARGETS)
 	@$(call MESSAGE,"Finalizing target directory")
+		$(HOST_DIR)/usr/bin/python -c "import compileall; \
+			compileall.compile_dir('$(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR)/site-packages')"
 	$(foreach hook,$(TARGET_FINALIZE_HOOKS),$($(hook))$(sep))
 	rm -rf $(TARGET_DIR)/usr/include $(TARGET_DIR)/usr/share/aclocal \
 		$(TARGET_DIR)/usr/lib/pkgconfig $(TARGET_DIR)/usr/share/pkgconfig \

More information about the buildroot mailing list