public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/
Date: Wed, 11 Nov 2015 10:27:42 +0000 (UTC)	[thread overview]
Message-ID: <1447237293.0f076c65649b8eda6480f8c44e4b85f583cdd014.mgorny@gentoo> (raw)

commit:     0f076c65649b8eda6480f8c44e4b85f583cdd014
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Nov  8 08:27:50 2015 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> 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: [<impl>]
+# @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: [<impl>]
 # @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


             reply	other threads:[~2015-11-11 10:27 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-11 10:27 Michał Górny [this message]
  -- strict thread matches above, loose matches on Subject: below --
2015-11-24 17:03 [gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/ Mike Frysinger
2015-12-09 20:42 Michał Górny
2016-01-08  5:14 Michał Górny
2016-01-08  5:14 Michał Górny
2016-06-26 15:36 Michał Górny
2016-06-27  5:58 Michał Górny
2016-12-18 13:46 Michał Górny
2017-02-09 18:16 Mike Frysinger
2017-03-18  7:33 Michał Górny
2017-08-08 19:42 Michał Górny
2017-08-11 14:35 Michał Górny
2017-08-25 13:53 Michał Górny
2017-09-19 11:08 Michał Górny
2017-09-26 18:46 Ulrich Müller
2018-01-04 21:56 Michał Górny
2018-04-18 18:13 Mike Gilbert
2019-12-24 11:01 Sergei Trofimovich
2019-12-30 12:59 Michał Górny
2019-12-30 12:59 Michał Górny
2020-01-11 23:53 Sergei Trofimovich
2020-03-26  7:51 Sergei Trofimovich
2020-03-28 19:54 Sergei Trofimovich
2020-05-25  6:12 Michał Górny
2021-01-05 23:01 Sergei Trofimovich
2021-01-15 17:05 Michał Górny
2021-06-23 21:44 Michał Górny
2022-01-09  8:09 Michał Górny
2022-02-09  9:39 Michał Górny
2022-05-01  7:30 Michał Górny
2022-09-28 20:55 Michał Górny
2022-10-10 20:52 Michał Górny
2022-11-15 16:34 Michał Górny
2023-06-07  9:03 Ulrich Müller
2023-06-18 14:57 Michał Górny
2023-06-18 14:57 Michał Górny
2023-07-02 15:21 Michał Górny
2023-09-14  5:30 Michał Górny
2024-02-10 10:47 Michał Górny
2024-02-10 10:47 Michał Górny
2024-10-08 15:29 Ulrich Müller
2025-03-03 19:27 Sam James

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1447237293.0f076c65649b8eda6480f8c44e4b85f583cdd014.mgorny@gentoo \
    --to=mgorny@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox