From patchwork Fri Sep 16 13:18:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederik Aalund X-Patchwork-Id: 670874 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sbG8910VGz9sC3 for ; Fri, 16 Sep 2016 23:19:05 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sbtaqua-com.20150623.gappssmtp.com header.i=@sbtaqua-com.20150623.gappssmtp.com header.b=KWX0qqK2; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 9FB4E8A877; Fri, 16 Sep 2016 13:19:03 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JTRXqV96puIX; Fri, 16 Sep 2016 13:19:03 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 14E058A915; Fri, 16 Sep 2016 13:19:03 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 81CAA1CF5F0 for ; Fri, 16 Sep 2016 13:19:01 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 7E1318A877 for ; Fri, 16 Sep 2016 13:19:01 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id i-BS6sR4upkA for ; Fri, 16 Sep 2016 13:19:00 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail-lf0-f50.google.com (mail-lf0-f50.google.com [209.85.215.50]) by hemlock.osuosl.org (Postfix) with ESMTPS id 97BDE8A915 for ; Fri, 16 Sep 2016 13:19:00 +0000 (UTC) Received: by mail-lf0-f50.google.com with SMTP id l131so61220389lfl.2 for ; Fri, 16 Sep 2016 06:19:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sbtaqua-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=7OjuHWg9nAUIproMD145ErUUFyb2D2TICCDAVQ3mKb8=; b=KWX0qqK293Y+CvfjMX4sFDp8nKWNUHNv7EPKCudNtHnLuIHMHU9xQ8fJ2DIY9jSTZr vpZCnff8hjKUdrmHznpDd26UOPpYRVwhOT7HLpt5YHwmaJ0YbTY/M2MddqTOI3f+TV4l Tz6SGTRZIX2Ey+pyWkJXrEndowLJTVGh84bhciN4LSEg0wwUnpKtUmxdWyxxWTTlrk6o m44bduC+DlPIODxoG8IJUGnlKxOsFs9NnC1Xe8BSCaJK4ZcrxWryHniBWLhuuJw8AhDm yBP+5vaTmDOYoEQkRo85Yn8f6XUQ/cPMHXt7jGQgDc/BQ7NfCjDZfjbkhyWMJEAakdV1 +/Kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=7OjuHWg9nAUIproMD145ErUUFyb2D2TICCDAVQ3mKb8=; b=e0AsVOKnbrxwxGNsAJwXn/zOaqNSIrjETJdTBlBZYzPeD48sNEk2S6nyazrc2JIF/G Uxu3m4qr8mMgYokaHxgw5vkbCj16sHueD0CvsOVeFGdzvo2P2yTG3RL3R33WF50mXzUO 1lCBlXUJPIAj5ldMnUBKo2E/dz+aDhhHL8g18KtlaxBIgUl8B6s+EJfpE699TvxKQKJ+ L+W+d5Iy7nF4wj/SEC6TQfjLKtmgUBDvD9su4EGfE8IM4iCB9aLifaGtbxm4XBAWL9Eq gvgSc+SQwuE4xujVT6FhQJVeTQKINk9WTFS2YCkH3VnDkJkGWAPTPRmEO1a4eBKMU1AZ 3lWQ== X-Gm-Message-State: AE9vXwOcFmCaijSH5JdirbBqmlSuHj+Q3KDy1EEO2u6TTjvt5aQ9BgpBMzounEK4rrSfpQ== X-Received: by 10.46.0.156 with SMTP id e28mr5705129lji.59.1474031938395; Fri, 16 Sep 2016 06:18:58 -0700 (PDT) Received: from localhost.localdomain ([77.72.50.193]) by smtp.gmail.com with ESMTPSA id s21sm2291756lfg.13.2016.09.16.06.18.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Sep 2016 06:18:57 -0700 (PDT) From: Frederik Aalund To: buildroot@buildroot.org Date: Fri, 16 Sep 2016 15:18:21 +0200 Message-Id: <1474031901-20941-1-git-send-email-fpa@sbtaqua.com> X-Mailer: git-send-email 2.5.0 Cc: Frederik Aalund Subject: [Buildroot] [PATCH 2/2] python3: Using PYTHON3_PYC_ONLY created an incomplete python installation X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" The PYTHON3_PYC_ONLY option did the following: * Compile `*.py` into `__pycache__/*.pyc` files * Delete `*.py` files I've changed it to do the following: * Compile `*.py` into `*.pyc` files * Delete `*.py` files The problem with the old behaviour is that python does *not* look into the `__pycache__` directory if the `*.py` file is missing. Python will, however, find a `*.pyc` file where the `*.py` file was supposed to be. This is by design (PEP 3147). The change of behaviour in this patch is accomplished by passing `legacy=True` to `compileall`. I've adopted `compileall`'s command line interface for `pycompile` and used `-b` to denote `legacy=True`. Signed-off-by: Frederik Aalund --- package/python3/python3.mk | 4 +++- support/scripts/pycompile.py | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/package/python3/python3.mk b/package/python3/python3.mk index 34e1297..1b63f95 100644 --- a/package/python3/python3.mk +++ b/package/python3/python3.mk @@ -213,7 +213,8 @@ define PYTHON3_CREATE_PYC_FILES PYTHONPATH="$(PYTHON3_PATH)" \ $(HOST_DIR)/usr/bin/python$(PYTHON3_VERSION_MAJOR) \ support/scripts/pycompile.py \ - $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR) + $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR) \ + $(PYTHON3_PYCOMPILE_ARGS) endef ifeq ($(BR2_PACKAGE_PYTHON3_PYC_ONLY)$(BR2_PACKAGE_PYTHON3_PY_PYC),y) @@ -226,6 +227,7 @@ define PYTHON3_REMOVE_PY_FILES xargs -0 --no-run-if-empty rm -f endef PYTHON3_TARGET_FINALIZE_HOOKS += PYTHON3_REMOVE_PY_FILES +PYTHON3_PYCOMPILE_ARGS += -b endif # Normally, *.pyc files should not have been compiled, but just in diff --git a/support/scripts/pycompile.py b/support/scripts/pycompile.py index fde711a..f9dee7f 100644 --- a/support/scripts/pycompile.py +++ b/support/scripts/pycompile.py @@ -21,4 +21,7 @@ class ReportProblem: report_problem = ReportProblem() -compileall.compile_dir(sys.argv[1], quiet=report_problem) +# Pass along the legacy parameter +legacy = '-b' in sys.argv + +compileall.compile_dir(sys.argv[1], legacy=legacy, quiet=report_problem)