Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Philippe Proulx <eeppeliteloop@gmail.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH] Makefile: fix Python 3 site packages when using PYC_ONLY
Date: Wed, 23 Jul 2014 20:57:26 -0400	[thread overview]
Message-ID: <1406163446-14581-1-git-send-email-eeppeliteloop@gmail.com> (raw)

The Python 3 standard lib is compiled into PYC bytecode using a
pre-PEP-3147 mode (.pyc files beside .py files; no __pycache__)
when BR2_PACKAGE_PYTHON3_PYC_ONLY is enabled. However, site packages
installed with setuptools/distutils are compiled following PEP-3147.
When BR2_PACKAGE_PYTHON3_PYC_ONLY is on, .py source files are removed
and Python 3 (target) will not look into __pycache__ directories
without associated .py files.

Python 2 does not suffer from this since PEP-3147 seems to be
implemented in Python 3 only.

This commit fixes this by compiling Python 3 site packages using a
pre-PEP-3147 mode after they are installed and then removing
__pycache__ directories.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
---
 Makefile | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/Makefile b/Makefile
index 6bd18e3..b38ccd9 100644
--- a/Makefile
+++ b/Makefile
@@ -574,7 +574,15 @@ ifeq ($(BR2_PACKAGE_PYTHON_PY_ONLY)$(BR2_PACKAGE_PYTHON3_PY_ONLY),y)
 	find $(TARGET_DIR)/usr/lib/ -name '*.pyc' -print0 | xargs -0 rm -f
 endif
 ifeq ($(BR2_PACKAGE_PYTHON_PYC_ONLY)$(BR2_PACKAGE_PYTHON3_PYC_ONLY),y)
+ifeq ($(BR2_PACKAGE_PYTHON3),y)
+	for sp in $(TARGET_DIR)/usr/lib/python3*/site-packages; do \
+		$(HOST_DIR)/usr/bin/python -m compileall -b $$sp; \
+	done
+endif
 	find $(TARGET_DIR)/usr/lib/ -name '*.py' -print0 | xargs -0 rm -f
+ifeq ($(BR2_PACKAGE_PYTHON3),y)
+	find $(TARGET_DIR)/usr/lib/python3* -name __pycache__ -type d -print0 | xargs -0 rm -rf
+endif
 endif
 	rm -rf $(TARGET_DIR)/usr/lib/luarocks
 	rm -rf $(TARGET_DIR)/usr/lib/perl5/$(PERL_VERSION)/pod
-- 
2.0.2

                 reply	other threads:[~2014-07-24  0:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1406163446-14581-1-git-send-email-eeppeliteloop@gmail.com \
    --to=eeppeliteloop@gmail.com \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox