1 |
Provide a proper multi-impl Python support for scons-utils in EAPI 7, |
2 |
to account for new versions of dev-util/scons (3.0.1-r100+, to be |
3 |
committed) that support Python 3 and break SConstruct files using |
4 |
Python 2 constructs. |
5 |
|
6 |
Combining scons-utils with python-any-r1 and python-single-r1 is added |
7 |
retroactively for older EAPIs as well, with fallback to Python 2.7. |
8 |
The new (hard-to-use) API for python-r1 is specific to EAPI 7 since it |
9 |
requires adding explicit BDEPEND. |
10 |
|
11 |
The new use of the eclass is described on the wiki page, along with |
12 |
series of examples covering different use cases: |
13 |
https://wiki.gentoo.org/wiki/Project:Python/scons-utils_integration |
14 |
--- |
15 |
eclass/scons-utils.eclass | 64 ++++++++++++++++++++++++++++++++++++--- |
16 |
1 file changed, 60 insertions(+), 4 deletions(-) |
17 |
|
18 |
diff --git a/eclass/scons-utils.eclass b/eclass/scons-utils.eclass |
19 |
index 5335968bc52e..615e00e314ad 100644 |
20 |
--- a/eclass/scons-utils.eclass |
21 |
+++ b/eclass/scons-utils.eclass |
22 |
@@ -9,6 +9,14 @@ |
23 |
# This eclass provides a set of function to help developers sanely call |
24 |
# dev-util/scons and pass parameters to it. |
25 |
# |
26 |
+# As of dev-util/scons-3.0.1-r100, SCons supports Python 3. Since |
27 |
+# SCons* files in build systems are written as Python, all packages |
28 |
+# need to explicitly verify which versions of Python are supported |
29 |
+# and use appropriate Python suite eclass to select the implementation. |
30 |
+# The eclass needs to be inherited before scons-utils, and scons-utils |
31 |
+# will automatically take advantage of it. For more details, please see: |
32 |
+# https://wiki.gentoo.org/wiki/Project:Python/scons-utils_integration |
33 |
+# |
34 |
# Please note that SCons is more like a 'build system creation kit', |
35 |
# and requires a lot of upstream customization to be used sanely. |
36 |
# You will often need to request fixes upstream and/or patch the build |
37 |
@@ -26,7 +34,8 @@ |
38 |
# |
39 |
# @EXAMPLE: |
40 |
# @CODE |
41 |
-# inherit scons-utils toolchain-funcs |
42 |
+# PYTHON_COMPAT=( python2_7 ) |
43 |
+# inherit python-any-r1 scons-utils toolchain-funcs |
44 |
# |
45 |
# EAPI=5 |
46 |
# |
47 |
@@ -93,7 +102,7 @@ |
48 |
# -- EAPI support check -- |
49 |
|
50 |
case ${EAPI:-0} in |
51 |
- 0|1|2|3|4|5|6) ;; |
52 |
+ 0|1|2|3|4|5|6|7) ;; |
53 |
*) die "EAPI ${EAPI} unsupported." |
54 |
esac |
55 |
|
56 |
@@ -102,9 +111,38 @@ inherit multiprocessing |
57 |
# -- ebuild variables setup -- |
58 |
|
59 |
if [[ -n ${SCONS_MIN_VERSION} ]]; then |
60 |
- BDEPEND=">=dev-util/scons-${SCONS_MIN_VERSION}" |
61 |
+ SCONS_DEPEND=">=dev-util/scons-${SCONS_MIN_VERSION}" |
62 |
else |
63 |
- BDEPEND="dev-util/scons" |
64 |
+ SCONS_DEPEND="dev-util/scons" |
65 |
+fi |
66 |
+ |
67 |
+if [[ ${_PYTHON_ANY_R1} ]]; then |
68 |
+ # when using python-any-r1, use any-of dep API |
69 |
+ BDEPEND="$(python_gen_any_dep "${SCONS_DEPEND}[\${PYTHON_USEDEP}]")" |
70 |
+ |
71 |
+ scons-utils_python_check_deps() { |
72 |
+ has_version "${SCONS_DEPEND}[${PYTHON_USEDEP}]" |
73 |
+ } |
74 |
+ python_check_deps() { scons-utils_python_check_deps; } |
75 |
+elif [[ ${_PYTHON_SINGLE_R1} ]]; then |
76 |
+ # when using python-single-r1, use plain PYTHON_USEDEP API |
77 |
+ BDEPEND="${SCONS_DEPEND}[${PYTHON_USEDEP}] |
78 |
+ ${PYTHON_DEPS}" |
79 |
+elif [[ ${EAPI:-0} == [0123456] ]]; then |
80 |
+ # in older EAPIs, just force Python 2.7 |
81 |
+ BDEPEND="${SCONS_DEPEND}[python_targets_python2_7]" |
82 |
+elif [[ ${_PYTHON_R1} ]]; then |
83 |
+ # when using python-r1, you need to depend on scons yourself |
84 |
+ # (depending on whether you need any-r1 or full -r1 API) |
85 |
+ # -- since this is a breaking API change, it applies to EAPI 7+ only |
86 |
+ BDEPEND="" |
87 |
+elif [[ ${EAPI:-0} != [0123456] ]]; then |
88 |
+ # in EAPI 7+, require appropriate eclass use |
89 |
+ eerror "Using scons-utils.eclass without any python-r1 suite eclass is not supported." |
90 |
+ eerror "Please make sure to configure and inherit appropriate -r1 eclass." |
91 |
+ eerror "For more information and examples, please see:" |
92 |
+ eerror " https://wiki.gentoo.org/wiki/Project:Python/scons-utils_integration" |
93 |
+ die "Invalid use of scons-utils.eclass" |
94 |
fi |
95 |
|
96 |
if [[ ${EAPI:-0} == [0123456] ]]; then |
97 |
@@ -124,6 +162,24 @@ escons() { |
98 |
|
99 |
debug-print-function ${FUNCNAME} "${@}" |
100 |
|
101 |
+ if [[ ! ${EPYTHON} ]]; then |
102 |
+ if [[ ${EAPI:-0} != [0123456] ]]; then |
103 |
+ eerror "EPYTHON is unset while calling escons. This most likely means that" |
104 |
+ eerror "the ebuild did not call the appropriate eclass function before calling scons." |
105 |
+ if [[ ${_PYTHON_ANY_R1} ]]; then |
106 |
+ eerror "Please ensure that python-any-r1_pkg_setup is called in pkg_setup()." |
107 |
+ elif [[ ${_PYTHON_SINGLE_R1} ]]; then |
108 |
+ eerror "Please ensure that python-single-r1_pkg_setup is called in pkg_setup()." |
109 |
+ else # python-r1 |
110 |
+ eerror "Please ensure that python_setup is called before escons, or that escons" |
111 |
+ eerror "is used within python_foreach_impl as appropriate." |
112 |
+ fi |
113 |
+ die "EPYTHON unset in escons" |
114 |
+ else |
115 |
+ local -x EPYTHON=python2.7 |
116 |
+ fi |
117 |
+ fi |
118 |
+ |
119 |
# Use myesconsargs in EAPI 5 and older |
120 |
if [[ ${EAPI} == [012345] ]]; then |
121 |
set -- "${myesconsargs[@]}" "${@}" |
122 |
-- |
123 |
2.17.0 |