1 |
--- |
2 |
gx86/eclass/python-r1.eclass | 66 ++++++++++++++++++++++++++++++++++++++++++++ |
3 |
1 file changed, 66 insertions(+) |
4 |
|
5 |
diff --git a/gx86/eclass/python-r1.eclass b/gx86/eclass/python-r1.eclass |
6 |
index 0d6ef4c..6d4eb33 100644 |
7 |
--- a/gx86/eclass/python-r1.eclass |
8 |
+++ b/gx86/eclass/python-r1.eclass |
9 |
@@ -363,6 +363,70 @@ python_copy_sources() { |
10 |
done |
11 |
} |
12 |
|
13 |
+# @FUNCTION: _python_check_USE_PYTHON |
14 |
+# @INTERNAL |
15 |
+# @DESCRIPTION: |
16 |
+# Check whether USE_PYTHON and PYTHON_TARGETS are in sync. Output |
17 |
+# warnings if they are not. |
18 |
+_python_check_USE_PYTHON() { |
19 |
+ if [[ ! ${_PYTHON_USE_PYTHON_CHECKED} ]]; then |
20 |
+ _PYTHON_USE_PYTHON_CHECKED=1 |
21 |
+ |
22 |
+ local USE_PYTHON=${USE_PYTHON} |
23 |
+ |
24 |
+ if [[ ! ${USE_PYTHON} ]]; then |
25 |
+ # default to selected Python2+3 |
26 |
+ if has_version app-admin/eselect-python; then |
27 |
+ local py2=$(eselect python show --python2) |
28 |
+ local py3=$(eselect python show --python3) |
29 |
+ |
30 |
+ USE_PYTHON="${py2#python} ${py3#python}" |
31 |
+ fi |
32 |
+ fi |
33 |
+ |
34 |
+ local impl warned |
35 |
+ for impl in "${PYTHON_COMPAT[@]}"; do |
36 |
+ local abi |
37 |
+ case "${impl}" in |
38 |
+ python*) |
39 |
+ abi=${impl#python} |
40 |
+ ;; |
41 |
+ jython*) |
42 |
+ abi=${impl#jython}-jython |
43 |
+ ;; |
44 |
+ pypy*) |
45 |
+ abi=2.7-pypy-${impl#pypy} |
46 |
+ ;; |
47 |
+ *) |
48 |
+ die "Unexpected Python implementation: ${impl}" |
49 |
+ ;; |
50 |
+ esac |
51 |
+ |
52 |
+ has "${abi/_/.}" ${USE_PYTHON} |
53 |
+ local has_abi=${?} |
54 |
+ use "python_targets_${impl}" |
55 |
+ local has_impl=${?} |
56 |
+ |
57 |
+ if [[ ${has_abi} != ${has_impl} ]]; then |
58 |
+ if [[ ! ${warned} ]]; then |
59 |
+ ewarn "PYTHON_TARGETS <-> USE_PYTHON inconsistency found. This may result" |
60 |
+ ewarn "in missing modules when trying to use Python packages. Please ensure" |
61 |
+ ewarn "that the same implementations are listed in both variables." |
62 |
+ ewarn |
63 |
+ |
64 |
+ warned=1 |
65 |
+ fi |
66 |
+ |
67 |
+ if [[ ${has_abi} == 0 ]]; then |
68 |
+ ewarn "Implementation ${impl} disabled but ${abi/_/.} in USE_PYTHON" |
69 |
+ else |
70 |
+ ewarn "Implementation ${impl} enabled but ${abi/_/.} not in USE_PYTHON" |
71 |
+ fi |
72 |
+ fi |
73 |
+ done |
74 |
+ fi |
75 |
+} |
76 |
+ |
77 |
# @FUNCTION: python_foreach_impl |
78 |
# @USAGE: <command> [<args>...] |
79 |
# @DESCRIPTION: |
80 |
@@ -376,6 +440,8 @@ python_copy_sources() { |
81 |
python_foreach_impl() { |
82 |
debug-print-function ${FUNCNAME} "${@}" |
83 |
|
84 |
+ _python_check_USE_PYTHON |
85 |
+ |
86 |
local impl |
87 |
local bdir=${BUILD_DIR:-${S}} |
88 |
|
89 |
-- |
90 |
1.7.12.4 |