From patchwork Sun Apr 5 18:47:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Barnett X-Patchwork-Id: 458270 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from hemlock.osuosl.org (hemlock.osuosl.org [140.211.166.133]) by ozlabs.org (Postfix) with ESMTP id B569814016A for ; Mon, 6 Apr 2015 04:48:18 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="verification failed; unprotected key" header.d=gmail.com header.i=@gmail.com header.b=GKc67PA1; dkim-adsp=none (unprotected policy); dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id BAF0B93972; Sun, 5 Apr 2015 18:48:17 +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 q+39oVu++Kye; Sun, 5 Apr 2015 18:48:17 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 184DA8B07E; Sun, 5 Apr 2015 18:48:17 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from hemlock.osuosl.org (hemlock.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id A50E81BF984 for ; Sun, 5 Apr 2015 18:48:15 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id A1D738B149 for ; Sun, 5 Apr 2015 18:48:15 +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 F44RMEzbOuag for ; Sun, 5 Apr 2015 18:48:14 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-vn0-f44.google.com (mail-vn0-f44.google.com [209.85.216.44]) by hemlock.osuosl.org (Postfix) with ESMTPS id 5F73A8B07E for ; Sun, 5 Apr 2015 18:48:14 +0000 (UTC) Received: by vnbg7 with SMTP id g7so1401816vnb.10 for ; Sun, 05 Apr 2015 11:48:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=+dg3dxTxU3yvfCrvDVoqgrHbw0n+FUCR891hHyotAN0=; b=GKc67PA1u3oCH9SXWV8FNdULd60T/rkNiJXeM5DOgzvp3uTw8KhlDfGQpSNkLMfNip fCsdxl7jHEu0Ff9t8L+syIXm9Cw2A0qATcza87af9EvKZfBG3bDkc2j257lXmZ6W2FFU PkEKkVMjO6xzaIz8ZCGFRCGsQ8nE33KkR0ARJT6dIxwEvE3/6IjVBiQcQZ4cQFv9o0HD fgY0e1RBqCUXalZFbRNWEBBbK6UseLLyULuxWaubsVWI9DD89wvR4u0MK+TRmOYSKjoV uOMzc6TZBZcAO7ygxShF87wcNW1BKm7CVFdLY/y50HZJLnpjb9KcaNbY6rzbg+deJEIH kx0A== X-Received: by 10.236.53.161 with SMTP id g21mr11079331yhc.23.1428259693338; Sun, 05 Apr 2015 11:48:13 -0700 (PDT) Received: from localhost.localdomain (50-83-61-125.client.mchsi.com. [50.83.61.125]) by mx.google.com with ESMTPSA id e47sm1952521yhj.38.2015.04.05.11.48.12 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 05 Apr 2015 11:48:12 -0700 (PDT) From: Ryan Barnett To: buildroot@buildroot.org Date: Sun, 5 Apr 2015 13:47:55 -0500 Message-Id: <1428259675-7116-1-git-send-email-ryanbarnett3@gmail.com> X-Mailer: git-send-email 1.9.1 Subject: [Buildroot] [PATCH 1/1] i2c-tools: add support to build python extension 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" Add a config option to build the python bindings for i2c-tools - py-smbus. The steps for building the python bindings is the same as the distutil steps that are a part of the python infrastructure. Signed-off-by: Ryan Barnett CC: Tjeerd Pinkert CC: Zoltan Gyarmati --- package/i2c-tools/Config.in | 13 +++++++++++++ package/i2c-tools/i2c-tools.mk | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/package/i2c-tools/Config.in b/package/i2c-tools/Config.in index e83dbd6..2e537cb 100644 --- a/package/i2c-tools/Config.in +++ b/package/i2c-tools/Config.in @@ -8,3 +8,16 @@ config BR2_PACKAGE_I2C_TOOLS EEPROM decoding scripts, and more. http://www.lm-sensors.org/wiki/I2CTools + +if BR2_PACKAGE_I2C_TOOLS + +config BR2_PACKAGE_I2C_TOOLS_PYSMBUS + bool "py-smbus" + depends on BR2_PACKAGE_PYTHON + help + Python bindings to smbus from the i2c-tools package. + +comment "i2c-tools py-smbux depends on python" + depends on !BR2_PACKAGE_PYTHON + +endif diff --git a/package/i2c-tools/i2c-tools.mk b/package/i2c-tools/i2c-tools.mk index 0115e22..f363505 100644 --- a/package/i2c-tools/i2c-tools.mk +++ b/package/i2c-tools/i2c-tools.mk @@ -21,4 +21,37 @@ define I2C_TOOLS_INSTALL_TARGET_CMDS done endef +# BASE_ENV taken from PKG_PYTHON_DISTUTILS_ENV in package/pkg-python.mk +I2C_TOOLS_PYTHON_BASE_ENV = PATH=$(BR_PATH) \ + CC="$(TARGET_CC)" \ + CFLAGS="$(TARGET_CFLAGS) -I../include" \ + LDFLAGS="$(TARGET_LDFLAGS)" \ + LDSHARED="$(TARGET_CROSS)gcc -shared" \ + PYTHONPATH="$(if $(BR2_PACKAGE_PYTHON3),$(PYTHON3_PATH),$(PYTHON_PATH))" \ + _python_sysroot=$(STAGING_DIR) \ + _python_prefix=/usr \ + _python_exec_prefix=/usr + +# Build/install steps mirror the distutil python package type in the python package +# infrastructure +ifeq ($(BR2_PACKAGE_I2C_TOOLS_PYSMBUS),y) +I2C_TOOLS_DEPENDENCIES += $(if $(BR2_PACKAGE_PYTHON3),host-python3 python3,host-python python) + +define I2C_TOOLS_BUILD_PYSMBUS + (cd $(@D)/py-smbus; \ + $(I2C_TOOLS_PYTHON_BASE_ENV) \ + $(HOST_DIR)/usr/bin/python setup.py build \ + --executable=/usr/bin/python) +endef +I2C_TOOLS_POST_BUILD_HOOKS += I2C_TOOLS_BUILD_PYSMBUS + +define I2C_TOOLS_INSTALL_PYSMBUS + (cd $(@D)/py-smbus; \ + $(I2C_TOOLS_PYTHON_BASE_ENV) \ + $(HOST_DIR)/usr/bin/python setup.py install \ + --prefix=$(TARGET_DIR)/usr ) +endef +I2C_TOOLS_POST_INSTALL_TARGET_HOOKS += I2C_TOOLS_INSTALL_PYSMBUS +endif + $(eval $(generic-package))