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 B58BE1384B4 for ; Wed, 11 Nov 2015 10:27:52 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id EE95D21C03C; Wed, 11 Nov 2015 10:27:47 +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 B944D21C039 for ; Wed, 11 Nov 2015 10:27:46 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id A4E83340634 for ; Wed, 11 Nov 2015 10:27:45 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 41B1B2407 for ; Wed, 11 Nov 2015 10:27:42 +0000 (UTC) From: "Michał Górny" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michał Górny" Message-ID: <1447237293.0f076c65649b8eda6480f8c44e4b85f583cdd014.mgorny@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/ X-VCS-Repository: repo/gentoo X-VCS-Files: eclass/python-utils-r1.eclass eclass/tests/python-utils-r1.sh X-VCS-Directories: eclass/ eclass/tests/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: 0f076c65649b8eda6480f8c44e4b85f583cdd014 X-VCS-Branch: master Date: Wed, 11 Nov 2015 10:27:42 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: fd52df75-b608-4ccd-b3c8-4e39c784b835 X-Archives-Hash: fffc391d936acddd21a96c4adb042b4f commit: 0f076c65649b8eda6480f8c44e4b85f583cdd014 Author: Michał Górny gentoo org> AuthorDate: Sun Nov 8 08:27:50 2015 +0000 Commit: Michał Górny gentoo org> CommitDate: Wed Nov 11 10:21:33 2015 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=0f076c65 python-utils-r1.eclass: Support getting PYTHON_CONFIG path 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