diff options
author | Michał Górny <mgorny@gentoo.org> | 2015-11-08 09:27:50 +0100 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2015-11-11 11:21:33 +0100 |
commit | 0f076c65649b8eda6480f8c44e4b85f583cdd014 (patch) | |
tree | 2da6c4c59fd0a9a129aef5975f575bacf9bc82dc /eclass/python-utils-r1.eclass | |
parent | python-utils-r1.eclass: Obtain PYTHON_SITEDIR from the interpreter (diff) | |
download | gentoo-0f076c65649b8eda6480f8c44e4b85f583cdd014.tar.gz gentoo-0f076c65649b8eda6480f8c44e4b85f583cdd014.tar.bz2 gentoo-0f076c65649b8eda6480f8c44e4b85f583cdd014.zip |
python-utils-r1.eclass: Support getting PYTHON_CONFIG path
Diffstat (limited to 'eclass/python-utils-r1.eclass')
-rw-r--r-- | eclass/python-utils-r1.eclass | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass index e8de6b9fd1e8..68926abe9da7 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: |