From patchwork Tue Feb 4 14:24:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnout Vandecappelle X-Patchwork-Id: 1233368 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=busybox.net (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mind.be Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=mind.be header.i=@mind.be header.a=rsa-sha256 header.s=google header.b=EwF+EqnN; dkim-atps=neutral Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48Bn6T0TdHzB3xs for ; Wed, 5 Feb 2020 01:25:37 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 1FA6687082; Tue, 4 Feb 2020 14:25:35 +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 CmzIlXGMN++U; Tue, 4 Feb 2020 14:25:34 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 53DDB8704A; Tue, 4 Feb 2020 14:25:34 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 748A31BF3D8 for ; Tue, 4 Feb 2020 14:25:33 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 71A0685166 for ; Tue, 4 Feb 2020 14:25:33 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Mh23aiM9mzik for ; Tue, 4 Feb 2020 14:25:32 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by fraxinus.osuosl.org (Postfix) with ESMTPS id F0C5384493 for ; Tue, 4 Feb 2020 14:25:31 +0000 (UTC) Received: by mail-wm1-f67.google.com with SMTP id t14so3883543wmi.5 for ; Tue, 04 Feb 2020 06:25:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mind.be; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zAwn2AtmWtTvVREdlizQgVxHO7D8zaFqsqmYwOvx2Yw=; b=EwF+EqnNj2F84lw+tdWDbiDtolBm3rEDS+VcUsHzV6BDA7J5uFOfdpfMZ93DsDW034 vQ5p5rD4S1hSEpKQ6mhcoeBgfUPtIRh7B53GVPb0aV4WmKFaKusdiOalT351fMJQFW81 XSu/4VrQRbxtufNJfg2H8HdqXXXTFg/4vsH/Kjz+qAjIsGbPBGE6UpMfm6ujFl9BnJPK ac0Rzk+rdtj7sOx0+WhiudGhN2/mWdFa2cpYIbtuepguVQsfyfI7rLOCmSM/uMaH7Q1q u1+2RrEHfRa0vxIfkzg+hDwWsJVcJI7iggFIRLQGnu0/FwiGTAk17MI21OOYLTJSwzyk jsrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zAwn2AtmWtTvVREdlizQgVxHO7D8zaFqsqmYwOvx2Yw=; b=M0s4OXIqj/9Jcxv5OcWwd10SQuC/CQpyAA5UhTBOyxYGvZx/UcHNnSs0FYmZc7TAEa f6JV2+ubmTOfqOHp4G1N/Sajhjf7yBxiaNx2MyPNGXWdHppJxPHrY/wn2E4jkqMvbga/ kSzQF70vw4w4e1SwWdjreaKEc0+8beBmM4fzsPzlDB81jkY+69flfYnGw7b1vqyRl41e 2LHpJ7hKQfDGIR1pKeFePEkdF2d7rcE/QMTdarAZOs8RbgU1VcutxY/nuAUF4MwYStJm cf3FFpra5rLTPDuSo1Y/oUe7MRcXgxjtTZIc4oFM7vdyIUPBB3s0dM8D3GIUZ5sI4/xc bQPw== X-Gm-Message-State: APjAAAVuddTmKSfy3XlU5IiBkD/P2u34ubkDAZ3jibOP6p1xJX70k+zj CKG27B6kA8iH/Iup56v+uSk8x7/S9TE= X-Google-Smtp-Source: APXvYqw0ilyJnJvfMXSWSJ56WV4CsaJHalpEh++ntJ0OvCh3NT9kWeqd6ZYyU4mlvQmLOlvxERNqXQ== X-Received: by 2002:a1c:6389:: with SMTP id x131mr5956330wmb.174.1580826329893; Tue, 04 Feb 2020 06:25:29 -0800 (PST) Received: from localhost.localdomain ([2620:0:1055:fd00:c6df:61c8:f82e:fd3c]) by smtp.gmail.com with ESMTPSA id x17sm29712678wrt.74.2020.02.04.06.25.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Feb 2020 06:25:29 -0800 (PST) From: "Arnout Vandecappelle (Essensium/Mind)" To: buildroot@buildroot.org Date: Tue, 4 Feb 2020 15:24:53 +0100 Message-Id: <20200204142456.1537358-3-arnout@mind.be> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200204142456.1537358-1-arnout@mind.be> References: <20200204142456.1537358-1-arnout@mind.be> MIME-Version: 1.0 Subject: [Buildroot] [PATCH 2/5] package/python3: install wrapper in HOST_BIN_CROSS X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Adam Duskett Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" When building python packages, we set some environment variables to make sure python picks up the correct configuration even though we're running host-python intead of target-python. Create a wrapper script that does the same, without requiring an explicit export from Buildroot. This script is installed in HOST_BIN_CROSS so that it can be found when cross-compiling. The script is made auto-discovering as much as possible. Since we know the script will be installed in $(HOST_DIR)/$(GNU_TARGET_NAME)/bin, we know that STAGING_DIR is at ../sysroot. sysconfigdata can be calculated based on that. Since this is specific for python3, we don't need the python3 condition. Only PYTHONPATH is still passed in explicitly, since that refers to TARGET_DIR - because most python packages are only installed in target and not in staging. So until we install everything in staging as well, we keep an explicit TARGET_DIR. Since the installation hook uses PYTHON3_PATH, move the definition of that variable higher in the file so it comes before its first use. It is not really necessary to have a similar script for native python, because the only environment variable we need in that case is PYTHONNOUSERSITE=1. Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- package/python3/python-wrapper.in | 24 ++++++++++++++++++++++++ package/python3/python3.mk | 17 ++++++++++++++--- 2 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 package/python3/python-wrapper.in diff --git a/package/python3/python-wrapper.in b/package/python3/python-wrapper.in new file mode 100644 index 0000000000..c2f34f32df --- /dev/null +++ b/package/python3/python-wrapper.in @@ -0,0 +1,24 @@ +#! /bin/sh + +STAGING_DIR=$(cd "${0%/*}/../sysroot"; pwd) + +SYSCONFIGDATA="" +for sysconfig in ${STAGING_DIR}/usr/lib/python*/_sysconfigdata__linux_*.py; do + if [ -n "$SYSCONFIGDATA" ]; then + echo "*** More than one sysconfigdata exists. Buildroot doesn't support mixing targets." 1>&2 + exit 1 + fi + if [ ! -r "$sysconfig" ]; then + echo "*** No sysconfigdata found in $sysconfig." 1>&2 + exit 1 + fi + SYSCONFIGDATA="$(echo $sysconfig | sed 's%.*/\([^/]*\).py%\1%')" +done + +PYTHONPATH="@PYTHON_PATH@" \ +PYTHONNOUSERSITE=1 \ +_PYTHON_SYSCONFIGDATA_NAME="$SYSCONFIGDATA" \ +_python_sysroot="$STAGING_DIR" \ +_python_prefix=/usr \ +_python_exec_prefix=/usr \ +exec "${0%/*}/../../bin/python3" "$@" diff --git a/package/python3/python3.mk b/package/python3/python3.mk index 9432f1c59e..6280b4a550 100644 --- a/package/python3/python3.mk +++ b/package/python3/python3.mk @@ -239,6 +239,20 @@ ifneq ($(BR2_PACKAGE_PYTHON),y) PYTHON3_POST_INSTALL_TARGET_HOOKS += PYTHON3_INSTALL_SYMLINK endif +# Provided to other packages +PYTHON3_PATH = $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/ + +define PYTHON3_INSTALL_CROSS_WRAPPER + mkdir -p $(HOST_BIN_CROSS) + sed 's%@PYTHON_PATH@%$(PYTHON3_PATH)%' \ + package/python3/python-wrapper.in \ + > $(HOST_BIN_CROSS)/python + chmod 0755 $(HOST_BIN_CROSS)/python + ln -sf python $(HOST_BIN_CROSS)/python3 +endef + +PYTHON3_POST_INSTALL_STAGING_HOOKS += PYTHON3_INSTALL_CROSS_WRAPPER + # Some packages may have build scripts requiring python3, whatever is the # python version chosen for the target. # Only install the python symlink in the host tree if python3 is enabled @@ -252,9 +266,6 @@ endef HOST_PYTHON3_POST_INSTALL_HOOKS += HOST_PYTHON3_INSTALL_SYMLINK endif -# Provided to other packages -PYTHON3_PATH = $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/ - # Support for socket.AF_BLUETOOTH ifeq ($(BR2_PACKAGE_BLUEZ5_UTILS_HEADERS),y) PYTHON3_DEPENDENCIES += bluez5_utils-headers