From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 659601384B4 for ; Sun, 8 Nov 2015 09:39:14 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 7D15A21C0D0; Sun, 8 Nov 2015 09:35:39 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 6CE4221C0C9 for ; Sun, 8 Nov 2015 09:35:38 +0000 (UTC) Received: from localhost.localdomain (d202-251.icpnet.pl [109.173.202.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mgorny) by smtp.gentoo.org (Postfix) with ESMTPSA id E39C1340562; Sun, 8 Nov 2015 09:35:31 +0000 (UTC) From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= To: gentoo-dev@lists.gentoo.org Cc: python@gentoo.org, =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Subject: [gentoo-dev] [PATCH 6/7] python-utils-r1.eclass: Support getting PYTHON_CONFIG path Date: Sun, 8 Nov 2015 10:35:10 +0100 Message-Id: <1446975311-19708-7-git-send-email-mgorny@gentoo.org> X-Mailer: git-send-email 2.6.3 In-Reply-To: <1446975311-19708-1-git-send-email-mgorny@gentoo.org> References: <1446975311-19708-1-git-send-email-mgorny@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Archives-Salt: d88a3428-2c06-498e-b796-7cc68fd0e000 X-Archives-Hash: ec59fb8e002e4825f420dd5814449e90 --- eclass/python-utils-r1.eclass | 47 +++++++++++++++++++++++++++++++++++++++++ eclass/tests/python-utils-r1.sh | 2 ++ 2 files changed, 49 insertions(+) diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass index e8de6b9..68926ab 100644 --- a/eclass/python-utils-r1.eclass +++ b/eclass/python-utils-r1.eclass @@ -190,6 +190,20 @@ _python_impl_supported() { # -lpython2.7 # @CODE +# @ECLASS-VARIABLE: PYTHON_CONFIG +# @DEFAULT_UNSET +# @DESCRIPTION: +# Path to the python-config executable. +# +# Set and exported on request using python_export(). +# Valid only for CPython. Requires a proper build-time dependency +# on the Python implementation and on pkg-config. +# +# Example value: +# @CODE +# /usr/bin/python2.7-config +# @CODE + # @ECLASS-VARIABLE: PYTHON_PKG_DEP # @DEFAULT_UNSET # @DESCRIPTION: @@ -323,6 +337,22 @@ python_export() { export PYTHON_LIBS=${val} debug-print "${FUNCNAME}: PYTHON_LIBS = ${PYTHON_LIBS}" ;; + PYTHON_CONFIG) + local flags val + + case "${impl}" in + python*) + flags=$("${PYTHON}" -c 'import sysconfig; print(sysconfig.get_config_var("ABIFLAGS") or "")') + val=${PYTHON}${flags}-config + ;; + *) + die "${impl}: obtaining ${var} not supported" + ;; + esac + + export PYTHON_CONFIG=${val} + debug-print "${FUNCNAME}: PYTHON_CONFIG = ${PYTHON_CONFIG}" + ;; PYTHON_PKG_DEP) local d case ${impl} in @@ -443,6 +473,23 @@ python_get_LIBS() { echo "${PYTHON_LIBS}" } +# @FUNCTION: python_get_PYTHON_CONFIG +# @USAGE: [] +# @DESCRIPTION: +# Obtain and print the PYTHON_CONFIG location for the given +# implementation. If no implementation is provided, ${EPYTHON} will be +# used. +# +# Please note that this function can be used with CPython only. +# It requires Python installed, and therefore proper build-time +# dependencies need be added to the ebuild. +python_get_PYTHON_CONFIG() { + debug-print-function ${FUNCNAME} "${@}" + + python_export "${@}" PYTHON_CONFIG + echo "${PYTHON_CONFIG}" +} + # @FUNCTION: python_get_scriptdir # @USAGE: [] # @DESCRIPTION: diff --git a/eclass/tests/python-utils-r1.sh b/eclass/tests/python-utils-r1.sh index 457756d..b683c51 100755 --- a/eclass/tests/python-utils-r1.sh +++ b/eclass/tests/python-utils-r1.sh @@ -67,6 +67,7 @@ if [[ -x /usr/bin/python2.7 ]]; then test_var PYTHON_SITEDIR python2_7 "/usr/lib*/python2.7/site-packages" test_var PYTHON_INCLUDEDIR python2_7 /usr/include/python2.7 test_var PYTHON_LIBPATH python2_7 "/usr/lib*/libpython2.7$(get_libname)" + test_var PYTHON_CONFIG python2_7 /usr/bin/python2.7-config fi test_var PYTHON_PKG_DEP python2_7 '*dev-lang/python*:2.7' test_var PYTHON_SCRIPTDIR python2_7 /usr/lib/python-exec/python2.7 @@ -78,6 +79,7 @@ if [[ -x /usr/bin/python3.4 ]]; then test_var PYTHON_SITEDIR python3_4 "/usr/lib*/python3.4/site-packages" test_var PYTHON_INCLUDEDIR python3_4 "/usr/include/python3.4${abiflags}" test_var PYTHON_LIBPATH python3_4 "/usr/lib*/libpython3.4${abiflags}$(get_libname)" + test_var PYTHON_CONFIG python3_4 "/usr/bin/python3.4${abiflags}-config" fi test_var PYTHON_PKG_DEP python3_4 '*dev-lang/python*:3.4' test_var PYTHON_SCRIPTDIR python3_4 /usr/lib/python-exec/python3.4 -- 2.6.3