From patchwork Tue Feb 4 14:24:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnout Vandecappelle X-Patchwork-Id: 1233369 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.138; helo=whitealder.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=Y/Ry86Zn; dkim-atps=neutral Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48Bn6q0dy1zB3xk for ; Wed, 5 Feb 2020 01:25:54 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id E82C3853F8; Tue, 4 Feb 2020 14:25:52 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id oCG4oSFgLUhB; Tue, 4 Feb 2020 14:25:52 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 07EF385218; Tue, 4 Feb 2020 14:25:52 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 09FC41BF3D8 for ; Tue, 4 Feb 2020 14:25:50 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 065EE20349 for ; Tue, 4 Feb 2020 14:25:50 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AqVIUpwwpjst for ; Tue, 4 Feb 2020 14:25:48 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by silver.osuosl.org (Postfix) with ESMTPS id AD8D42002B for ; Tue, 4 Feb 2020 14:25:47 +0000 (UTC) Received: by mail-wr1-f68.google.com with SMTP id u6so10018606wrt.0 for ; Tue, 04 Feb 2020 06:25:47 -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=+3cbWEBfnz5RiGOndZUjyydx7RSNjpkt9lk6vQv8n7Q=; b=Y/Ry86ZnsBQ0xKI1cBFoNSzQWUFdDEZaxEUIqg+mOzbunmh0jolR+IA3GSKfeKXzoC 5zdMVAO6m/clsbrT4bXE/5yV+5xvZvGEyAlWomApKqsOU5PXCRGezjv0x55wxcZNiojK UP4xQUs2sWgleZbNdX9+DjXn5GOHosWCDIQVvuvoHtUTrQ5sem7NeF/yZlfOURzVmgJD r2Z3rAUDSht79nKHKCD8VuLEG8PyRn1y+NCpZN2hMrKXbu2E6wWX+dBBsduL+38CVFJ8 RVaVA9kE2EHcFKZ0b/KGHUwNI0vwuuO2QCVuPG2Isw65Boyn4gyC1YQlhQX8CkVtg6EZ H2Qg== 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=+3cbWEBfnz5RiGOndZUjyydx7RSNjpkt9lk6vQv8n7Q=; b=ZEmLvoEvyJmvijkSCP3+LGKmHMe6pePBtkXBCrRU1aRzSwPX83j3raikzwPkOk6xjz UUx1fpbefiBVsmrrubweYJbJBsMNKChYlOkn7LCQFi4UuYNY1nTNdkHGhLQx4Js4XHkM rn65paSh1OTE38Gq3N4WoKTaGnLthTrGHhdV453fTpE83DKnywohD9Es6C72ZPB2yPy0 NqbIrvJ8km3B4wVTLKTK6EVvkTyykSCvplAHQYRxE2QLUzU+JwNtIEEYqHWbEZAu4CrJ nuKHETGzZy+KUNuLS8EtgHs9OSzn0uUnvK3l1L9JU0eA2DJoyWxoMMlK+3GQVJGbpQxC vYMw== X-Gm-Message-State: APjAAAVUINXXkYibQqNbAQSZBWiuq8v6yqh9qxX/wlnREKVNGLfkxBxB y24H3AZBLEg0/GSzZ77QF5jfpc9S7Kw= X-Google-Smtp-Source: APXvYqzJLWtDb1yI6dfVq+ESzv3t6xmEy3XFqHaqQd6Jj+AJX4rd6mDRf6EOmAsvjPBx7wHS68yOAg== X-Received: by 2002:adf:f091:: with SMTP id n17mr21693701wro.387.1580826345948; Tue, 04 Feb 2020 06:25:45 -0800 (PST) Received: from localhost.localdomain ([2620:0:1055:fd00:c6df:61c8:f82e:fd3c]) by smtp.gmail.com with ESMTPSA id s65sm4163277wmf.48.2020.02.04.06.25.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Feb 2020 06:25:45 -0800 (PST) From: "Arnout Vandecappelle (Essensium/Mind)" To: buildroot@buildroot.org Date: Tue, 4 Feb 2020 15:24:54 +0100 Message-Id: <20200204142456.1537358-4-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 3/5] package/python: 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. 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. sysconfigdata is not needed for python2 because it is not "multilib": there is only a target sysonfigdata module in STAGING_DIR. Since the installation hook uses PYTHON_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/python/python-wrapper.in | 10 ++++++++++ package/python/python.mk | 17 ++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 package/python/python-wrapper.in diff --git a/package/python/python-wrapper.in b/package/python/python-wrapper.in new file mode 100644 index 0000000000..c5e6e5481b --- /dev/null +++ b/package/python/python-wrapper.in @@ -0,0 +1,10 @@ +#! /bin/sh + +STAGING_DIR=$(cd "${0%/*}/../sysroot"; pwd) + +PYTHONPATH="@PYTHON_PATH@" \ +PYTHONNOUSERSITE=1 \ +_python_sysroot="$STAGING_DIR" \ +_python_prefix=/usr \ +_python_exec_prefix=/usr \ +exec "${0%/*}/../../bin/python" "$@" diff --git a/package/python/python.mk b/package/python/python.mk index 41a981e3d3..6f2e01386e 100644 --- a/package/python/python.mk +++ b/package/python/python.mk @@ -227,6 +227,20 @@ PYTHON_POST_INSTALL_STAGING_HOOKS += PYTHON_INSTALL_STAGING_PYTHON_CONFIG_SYMLIN PYTHON_AUTORECONF = YES +# Provided to other packages +PYTHON_PATH = $(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR)/sysconfigdata/ + +define PYTHON_INSTALL_CROSS_WRAPPER + mkdir -p $(HOST_BIN_CROSS) + sed 's%@PYTHON_PATH@%$(PYTHON_PATH)%' \ + package/python/python-wrapper.in \ + > $(HOST_BIN_CROSS)/python + chmod 0755 $(HOST_BIN_CROSS)/python + ln -sf python $(HOST_BIN_CROSS)/python2 +endef + +PYTHON_POST_INSTALL_STAGING_HOOKS += PYTHON_INSTALL_CROSS_WRAPPER + # Some packages may have build scripts requiring python2. # Only install the python symlink in the host tree if python3 is not enabled # for the target, otherwise the default python program may be missing. @@ -239,9 +253,6 @@ endef HOST_PYTHON_POST_INSTALL_HOOKS += HOST_PYTHON_INSTALL_PYTHON_SYMLINK endif -# Provided to other packages -PYTHON_PATH = $(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR)/sysconfigdata/ - $(eval $(autotools-package)) $(eval $(host-autotools-package))