1 |
--- |
2 |
eclass/python-utils-r1.eclass | 47 +++++++++++++++++++++++++++++++++++++++++ |
3 |
eclass/tests/python-utils-r1.sh | 2 ++ |
4 |
2 files changed, 49 insertions(+) |
5 |
|
6 |
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass |
7 |
index e8de6b9..68926ab 100644 |
8 |
--- a/eclass/python-utils-r1.eclass |
9 |
+++ b/eclass/python-utils-r1.eclass |
10 |
@@ -190,6 +190,20 @@ _python_impl_supported() { |
11 |
# -lpython2.7 |
12 |
# @CODE |
13 |
|
14 |
+# @ECLASS-VARIABLE: PYTHON_CONFIG |
15 |
+# @DEFAULT_UNSET |
16 |
+# @DESCRIPTION: |
17 |
+# Path to the python-config executable. |
18 |
+# |
19 |
+# Set and exported on request using python_export(). |
20 |
+# Valid only for CPython. Requires a proper build-time dependency |
21 |
+# on the Python implementation and on pkg-config. |
22 |
+# |
23 |
+# Example value: |
24 |
+# @CODE |
25 |
+# /usr/bin/python2.7-config |
26 |
+# @CODE |
27 |
+ |
28 |
# @ECLASS-VARIABLE: PYTHON_PKG_DEP |
29 |
# @DEFAULT_UNSET |
30 |
# @DESCRIPTION: |
31 |
@@ -323,6 +337,22 @@ python_export() { |
32 |
export PYTHON_LIBS=${val} |
33 |
debug-print "${FUNCNAME}: PYTHON_LIBS = ${PYTHON_LIBS}" |
34 |
;; |
35 |
+ PYTHON_CONFIG) |
36 |
+ local flags val |
37 |
+ |
38 |
+ case "${impl}" in |
39 |
+ python*) |
40 |
+ flags=$("${PYTHON}" -c 'import sysconfig; print(sysconfig.get_config_var("ABIFLAGS") or "")') |
41 |
+ val=${PYTHON}${flags}-config |
42 |
+ ;; |
43 |
+ *) |
44 |
+ die "${impl}: obtaining ${var} not supported" |
45 |
+ ;; |
46 |
+ esac |
47 |
+ |
48 |
+ export PYTHON_CONFIG=${val} |
49 |
+ debug-print "${FUNCNAME}: PYTHON_CONFIG = ${PYTHON_CONFIG}" |
50 |
+ ;; |
51 |
PYTHON_PKG_DEP) |
52 |
local d |
53 |
case ${impl} in |
54 |
@@ -443,6 +473,23 @@ python_get_LIBS() { |
55 |
echo "${PYTHON_LIBS}" |
56 |
} |
57 |
|
58 |
+# @FUNCTION: python_get_PYTHON_CONFIG |
59 |
+# @USAGE: [<impl>] |
60 |
+# @DESCRIPTION: |
61 |
+# Obtain and print the PYTHON_CONFIG location for the given |
62 |
+# implementation. If no implementation is provided, ${EPYTHON} will be |
63 |
+# used. |
64 |
+# |
65 |
+# Please note that this function can be used with CPython only. |
66 |
+# It requires Python installed, and therefore proper build-time |
67 |
+# dependencies need be added to the ebuild. |
68 |
+python_get_PYTHON_CONFIG() { |
69 |
+ debug-print-function ${FUNCNAME} "${@}" |
70 |
+ |
71 |
+ python_export "${@}" PYTHON_CONFIG |
72 |
+ echo "${PYTHON_CONFIG}" |
73 |
+} |
74 |
+ |
75 |
# @FUNCTION: python_get_scriptdir |
76 |
# @USAGE: [<impl>] |
77 |
# @DESCRIPTION: |
78 |
diff --git a/eclass/tests/python-utils-r1.sh b/eclass/tests/python-utils-r1.sh |
79 |
index 457756d..b683c51 100755 |
80 |
--- a/eclass/tests/python-utils-r1.sh |
81 |
+++ b/eclass/tests/python-utils-r1.sh |
82 |
@@ -67,6 +67,7 @@ if [[ -x /usr/bin/python2.7 ]]; then |
83 |
test_var PYTHON_SITEDIR python2_7 "/usr/lib*/python2.7/site-packages" |
84 |
test_var PYTHON_INCLUDEDIR python2_7 /usr/include/python2.7 |
85 |
test_var PYTHON_LIBPATH python2_7 "/usr/lib*/libpython2.7$(get_libname)" |
86 |
+ test_var PYTHON_CONFIG python2_7 /usr/bin/python2.7-config |
87 |
fi |
88 |
test_var PYTHON_PKG_DEP python2_7 '*dev-lang/python*:2.7' |
89 |
test_var PYTHON_SCRIPTDIR python2_7 /usr/lib/python-exec/python2.7 |
90 |
@@ -78,6 +79,7 @@ if [[ -x /usr/bin/python3.4 ]]; then |
91 |
test_var PYTHON_SITEDIR python3_4 "/usr/lib*/python3.4/site-packages" |
92 |
test_var PYTHON_INCLUDEDIR python3_4 "/usr/include/python3.4${abiflags}" |
93 |
test_var PYTHON_LIBPATH python3_4 "/usr/lib*/libpython3.4${abiflags}$(get_libname)" |
94 |
+ test_var PYTHON_CONFIG python3_4 "/usr/bin/python3.4${abiflags}-config" |
95 |
fi |
96 |
test_var PYTHON_PKG_DEP python3_4 '*dev-lang/python*:3.4' |
97 |
test_var PYTHON_SCRIPTDIR python3_4 /usr/lib/python-exec/python3.4 |
98 |
-- |
99 |
2.6.3 |