1 |
Now ebuilds can declare python_check_deps() function. It will be called |
2 |
with EPYTHON and PYTHON_USEDEP set for the impl, and it can do whatever |
3 |
to check whether the impl in question is fine with them, then return |
4 |
an appropriate boolean status. |
5 |
--- |
6 |
gx86/eclass/python-any-r1.eclass | 40 ++++++++++++++++++++++++++++++++++++++-- |
7 |
1 file changed, 38 insertions(+), 2 deletions(-) |
8 |
|
9 |
diff --git a/gx86/eclass/python-any-r1.eclass b/gx86/eclass/python-any-r1.eclass |
10 |
index d222155..88b5752 100644 |
11 |
--- a/gx86/eclass/python-any-r1.eclass |
12 |
+++ b/gx86/eclass/python-any-r1.eclass |
13 |
@@ -20,6 +20,14 @@ |
14 |
# pkg_setup() which finds the best supported implementation and sets it |
15 |
# as the active one. |
16 |
# |
17 |
+# Optionally, you can define a python_check_deps() function. It will |
18 |
+# be called by the eclass with EPYTHON set to each matching Python |
19 |
+# implementation and it is expected to check whether the implementation |
20 |
+# fulfills the package requirements. You can use the locally exported |
21 |
+# PYTHON_USEDEP to check USE-dependencies of relevant packages. It |
22 |
+# should return a true value (0) if the Python implementation fulfills |
23 |
+# the requirements, a false value (non-zero) otherwise. |
24 |
+# |
25 |
# Please note that python-any-r1 will always inherit python-utils-r1 |
26 |
# as well. Thus, all the functions defined there can be used in the |
27 |
# packages using python-any-r1, and there is no need ever to inherit |
28 |
@@ -134,16 +142,38 @@ _python_build_set_globals() { |
29 |
} |
30 |
_python_build_set_globals |
31 |
|
32 |
+# @ECLASS-VARIABLE: PYTHON_USEDEP |
33 |
+# @DESCRIPTION: |
34 |
+# An eclass-generated USE-dependency string for the currently tested |
35 |
+# implementation. It is set locally for python_check_deps() call. |
36 |
+# |
37 |
+# The generate USE-flag list is compatible with packages using python-r1, |
38 |
+# python-single-r1 and python-distutils-ng eclasses. It must not be used |
39 |
+# on packages using python.eclass. |
40 |
+# |
41 |
+# Example use: |
42 |
+# @CODE |
43 |
+# python_check_deps() { |
44 |
+# has_version "dev-python/foo[${PYTHON_USEDEP}]" |
45 |
+# } |
46 |
+# @CODE |
47 |
+# |
48 |
+# Example value: |
49 |
+# @CODE |
50 |
+# python_targets_python2_7(-)?,python_single_target_python2_7(+)? |
51 |
+# @CODE |
52 |
+ |
53 |
# @FUNCTION: _python_EPYTHON_supported |
54 |
# @USAGE: <epython> |
55 |
# @INTERNAL |
56 |
# @DESCRIPTION: |
57 |
# Check whether the specified implementation is supported by package |
58 |
-# (specified in PYTHON_COMPAT). |
59 |
+# (specified in PYTHON_COMPAT). Calls python_check_deps() if declared. |
60 |
_python_EPYTHON_supported() { |
61 |
debug-print-function ${FUNCNAME} "${@}" |
62 |
|
63 |
- local i=${1/./_} |
64 |
+ local EPYTHON=${1} |
65 |
+ local i=${EPYTHON/./_} |
66 |
|
67 |
case "${i}" in |
68 |
python*|jython*) |
69 |
@@ -161,6 +191,12 @@ _python_EPYTHON_supported() { |
70 |
local PYTHON_PKG_DEP |
71 |
python_export "${i}" PYTHON_PKG_DEP |
72 |
if ROOT=/ has_version "${PYTHON_PKG_DEP}"; then |
73 |
+ if declare -f python_check_deps >/dev/null; then |
74 |
+ local PYTHON_USEDEP="python_targets_${i}(-),python_single_target_${i}(+)" |
75 |
+ python_check_deps |
76 |
+ return ${?} |
77 |
+ fi |
78 |
+ |
79 |
return 0 |
80 |
fi |
81 |
elif ! has "${i}" "${_PYTHON_ALL_IMPLS[@]}"; then |
82 |
-- |
83 |
1.8.1.5 |