1 |
As described in the ml, the new function does: |
2 |
|
3 |
* in python-any-r1, choose and set up the best installed impl, |
4 |
|
5 |
* in python-single-r1, read PYTHON_SINGLE_TARGET and set it up, |
6 |
|
7 |
* in python-r1, call python_export_best + python_wrapper_setup. |
8 |
|
9 |
In other words, it's a common way of getting Python build environment |
10 |
set up in the ebuild scope. |
11 |
--- |
12 |
eclass/python-any-r1.eclass | 24 +++++++++++++++++------- |
13 |
eclass/python-r1.eclass | 15 +++++++++++++++ |
14 |
eclass/python-single-r1.eclass | 17 +++++++++++++---- |
15 |
3 files changed, 45 insertions(+), 11 deletions(-) |
16 |
|
17 |
diff --git a/eclass/python-any-r1.eclass b/eclass/python-any-r1.eclass |
18 |
index 760e8e7..109c4ee 100644 |
19 |
--- a/eclass/python-any-r1.eclass |
20 |
+++ b/eclass/python-any-r1.eclass |
21 |
@@ -259,17 +259,15 @@ _python_EPYTHON_supported() { |
22 |
return 1 |
23 |
} |
24 |
|
25 |
-# @FUNCTION: python-any-r1_pkg_setup |
26 |
+# @FUNCTION: python_setup |
27 |
# @DESCRIPTION: |
28 |
# Determine what the best installed (and supported) Python |
29 |
-# implementation is and set EPYTHON and PYTHON accordingly. |
30 |
-python-any-r1_pkg_setup() { |
31 |
+# implementation is, and set the Python build environment up for it. |
32 |
+# |
33 |
+# This function will call python_check_deps() if defined. |
34 |
+python_setup() { |
35 |
debug-print-function ${FUNCNAME} "${@}" |
36 |
|
37 |
- # avoid looking up Python for binary package install. |
38 |
- # if you need Python during pkg_preinst/_postinst, please let us know. |
39 |
- [[ ${MERGE_TYPE} == binary ]] && return 0 |
40 |
- |
41 |
# first, try ${EPYTHON}... maybe it's good enough for us. |
42 |
if [[ ${EPYTHON} ]]; then |
43 |
if _python_EPYTHON_supported "${EPYTHON}"; then |
44 |
@@ -317,5 +315,17 @@ python-any-r1_pkg_setup() { |
45 |
die "No supported Python implementation installed." |
46 |
} |
47 |
|
48 |
+# @FUNCTION: python-any-r1_pkg_setup |
49 |
+# @DESCRIPTION: |
50 |
+# Runs python_setup during from-source installs. |
51 |
+# |
52 |
+# In a binary package installs is a no-op. If you need Python in pkg_* |
53 |
+# phases of a binary package, call python_setup directly. |
54 |
+python-any-r1_pkg_setup() { |
55 |
+ debug-print-function ${FUNCNAME} "${@}" |
56 |
+ |
57 |
+ [[ ${MERGE_TYPE} != binary ]] && python_setup |
58 |
+} |
59 |
+ |
60 |
_PYTHON_ANY_R1=1 |
61 |
fi |
62 |
diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass |
63 |
index 750fa91..1a04d5b 100644 |
64 |
--- a/eclass/python-r1.eclass |
65 |
+++ b/eclass/python-r1.eclass |
66 |
@@ -712,6 +712,21 @@ python_parallel_foreach_impl() { |
67 |
multibuild_parallel_foreach_variant _python_multibuild_wrapper "${@}" |
68 |
} |
69 |
|
70 |
+# @FUNCTION: python_setup |
71 |
+# @DESCRIPTION: |
72 |
+# Find the best (most preferred) Python implementation enabled |
73 |
+# and set the Python build environment up for it. |
74 |
+# |
75 |
+# This function needs to be used when Python is being called outside |
76 |
+# of python_foreach_impl calls (e.g. for shared processes like doc |
77 |
+# building). python_foreach_impl sets up the build environment itself. |
78 |
+python_setup() { |
79 |
+ debug-print-function ${FUNCNAME} "${@}" |
80 |
+ |
81 |
+ python_export_best |
82 |
+ python_wrapper_setup |
83 |
+} |
84 |
+ |
85 |
# @FUNCTION: python_export_best |
86 |
# @USAGE: [<variable>...] |
87 |
# @DESCRIPTION: |
88 |
diff --git a/eclass/python-single-r1.eclass b/eclass/python-single-r1.eclass |
89 |
index 30bbab4..5ff3d40 100644 |
90 |
--- a/eclass/python-single-r1.eclass |
91 |
+++ b/eclass/python-single-r1.eclass |
92 |
@@ -202,11 +202,11 @@ _python_single_set_globals() { |
93 |
} |
94 |
_python_single_set_globals |
95 |
|
96 |
-# @FUNCTION: python-single-r1_pkg_setup |
97 |
+# @FUNCTION: python_setup |
98 |
# @DESCRIPTION: |
99 |
-# Determine what the selected Python implementation is and set EPYTHON |
100 |
-# and PYTHON accordingly. |
101 |
-python-single-r1_pkg_setup() { |
102 |
+# Determine what the selected Python implementation is and set |
103 |
+# the Python build environment up for it. |
104 |
+python_setup() { |
105 |
debug-print-function ${FUNCNAME} "${@}" |
106 |
|
107 |
unset EPYTHON |
108 |
@@ -250,6 +250,15 @@ python-single-r1_pkg_setup() { |
109 |
fi |
110 |
} |
111 |
|
112 |
+# @FUNCTION: python-single-r1_pkg_setup |
113 |
+# @DESCRIPTION: |
114 |
+# Runs python_setup. |
115 |
+python-single-r1_pkg_setup() { |
116 |
+ debug-print-function ${FUNCNAME} "${@}" |
117 |
+ |
118 |
+ python_setup |
119 |
+} |
120 |
+ |
121 |
# @FUNCTION: python_fix_shebang |
122 |
# @USAGE: <path>... |
123 |
# @DESCRIPTION: |
124 |
-- |
125 |
1.8.4 |