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

Yegor Yefremov yegorslists at googlemail.com
Mon Mar 9 16:37:10 UTC 2015


On Mon, Mar 9, 2015 at 5:24 PM, Samuel Martin <s.martin49 at gmail.com> wrote:
> 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>

Tested-by: Yegor Yefremov <yegorslists at googlemail.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")
> +ifneq ($(BR2_PACKAGE_PYTHON)$(BR2_PACKAGE_PYTHON3),)
> +       PYTHONPATH="$(PYTHON_PATH)" \
> +               $(HOST_DIR)/usr/bin/python -c "import compileall; \
> +                       compileall.compile_dir('$(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR)/site-packages')"
> +endif
>         $(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 \
> --
> 2.1.0
>



More information about the buildroot mailing list