1 |
This function can be used to obtain PYTHON & EPYTHON variables for any |
2 |
Python implementation supported. |
3 |
--- |
4 |
gx86/eclass/distutils-r1.eclass | 2 +- |
5 |
gx86/eclass/python-r1.eclass | 85 +++++++++++++++++++++++++++-------------- |
6 |
2 files changed, 57 insertions(+), 30 deletions(-) |
7 |
|
8 |
diff --git a/gx86/eclass/distutils-r1.eclass b/gx86/eclass/distutils-r1.eclass |
9 |
index 1b734b2..4370b4f 100644 |
10 |
--- a/gx86/eclass/distutils-r1.eclass |
11 |
+++ b/gx86/eclass/distutils-r1.eclass |
12 |
@@ -256,7 +256,7 @@ distutils-r1_python_install_all() { |
13 |
local impl EPYTHON PYTHON |
14 |
for impl in "${PYTHON_COMPAT[@]}"; do |
15 |
if use "python_targets_${impl}"; then |
16 |
- _python_set_PYTHON "${impl}" |
17 |
+ python_export "${impl}" EPYTHON |
18 |
break |
19 |
fi |
20 |
done |
21 |
diff --git a/gx86/eclass/python-r1.eclass b/gx86/eclass/python-r1.eclass |
22 |
index 89fc0e7..5ca51f6 100644 |
23 |
--- a/gx86/eclass/python-r1.eclass |
24 |
+++ b/gx86/eclass/python-r1.eclass |
25 |
@@ -154,34 +154,6 @@ _python_set_globals() { |
26 |
} |
27 |
_python_set_globals |
28 |
|
29 |
-# @FUNCTION: _python_set_PYTHON |
30 |
-# @USAGE: <impl> |
31 |
-# @INTERNAL |
32 |
-# @DESCRIPTION: |
33 |
-# Get the Python executable name for the given implementation and set it |
34 |
-# as ${PYTHON} & ${EPYTHON}. Please note that EPYTHON will contain |
35 |
-# the 'basename' while PYTHON will contain the full path. |
36 |
-_python_set_PYTHON() { |
37 |
- debug-print-function ${FUNCNAME} "${@}" |
38 |
- |
39 |
- local impl=${1/_/.} |
40 |
- |
41 |
- case "${impl}" in |
42 |
- python*|jython*) |
43 |
- EPYTHON=${impl} |
44 |
- ;; |
45 |
- pypy*) |
46 |
- EPYTHON=pypy-c${impl#pypy} |
47 |
- ;; |
48 |
- *) |
49 |
- die "Invalid argument to _python_set_PYTHON: ${1}" |
50 |
- ;; |
51 |
- esac |
52 |
- PYTHON=${EPREFIX}/usr/bin/${EPYTHON} |
53 |
- |
54 |
- debug-print "${FUNCNAME}: ${impl} -> ${PYTHON}" |
55 |
-} |
56 |
- |
57 |
# @ECLASS-VARIABLE: BUILD_DIR |
58 |
# @DESCRIPTION: |
59 |
# The current build directory. In global scope, it is supposed to |
60 |
@@ -221,6 +193,61 @@ _python_set_PYTHON() { |
61 |
# python2.6 |
62 |
# @CODE |
63 |
|
64 |
+# @FUNCTION: python_export |
65 |
+# @USAGE: [<impl>] <variables>... |
66 |
+# @DESCRIPTION: |
67 |
+# Set and export the Python implementation-relevant variables passed |
68 |
+# as parameters. |
69 |
+# |
70 |
+# The optional first parameter may specify the requested Python |
71 |
+# implementation (either as PYTHON_TARGETS value, e.g. python2_7, |
72 |
+# or an EPYTHON one, e.g. python2.7). If no implementation passed, |
73 |
+# the current one will be obtained from ${EPYTHON}. |
74 |
+# |
75 |
+# The variables which can be exported are: PYTHON, EPYTHON. They are |
76 |
+# described more completely in the eclass variable documentation. |
77 |
+python_export() { |
78 |
+ debug-print-function ${FUNCNAME} "${@}" |
79 |
+ |
80 |
+ local impl var |
81 |
+ |
82 |
+ case "${1}" in |
83 |
+ python*|jython*) |
84 |
+ impl=${1/_/.} |
85 |
+ shift |
86 |
+ ;; |
87 |
+ pypy-c*) |
88 |
+ impl=${1} |
89 |
+ shift |
90 |
+ ;; |
91 |
+ pypy*) |
92 |
+ local v=${1#pypy} |
93 |
+ impl=pypy-c${v/_/.} |
94 |
+ shift |
95 |
+ ;; |
96 |
+ *) |
97 |
+ impl=${EPYTHON} |
98 |
+ [[ ${impl} ]] || die "python_export: no impl nor EPYTHON" |
99 |
+ ;; |
100 |
+ esac |
101 |
+ debug-print "${FUNCNAME}: implementation: ${impl}" |
102 |
+ |
103 |
+ for var; do |
104 |
+ case "${var}" in |
105 |
+ EPYTHON) |
106 |
+ export EPYTHON=${impl} |
107 |
+ debug-print "${FUNCNAME}: EPYTHON = ${EPYTHON}" |
108 |
+ ;; |
109 |
+ PYTHON) |
110 |
+ export PYTHON=${EPREFIX}/usr/bin/${impl} |
111 |
+ debug-print "${FUNCNAME}: PYTHON = ${PYTHON}" |
112 |
+ ;; |
113 |
+ *) |
114 |
+ die "python_export: unknown variable ${var}" |
115 |
+ esac |
116 |
+ done |
117 |
+} |
118 |
+ |
119 |
# @FUNCTION: python_copy_sources |
120 |
# @DESCRIPTION: |
121 |
# Create a single copy of the package sources (${S}) for each enabled |
122 |
@@ -275,7 +302,7 @@ python_foreach_impl() { |
123 |
if has "${impl}" "${PYTHON_COMPAT[@]}" && use "python_targets_${impl}" |
124 |
then |
125 |
local EPYTHON PYTHON |
126 |
- _python_set_PYTHON "${impl}" |
127 |
+ python_export "${impl}" EPYTHON PYTHON |
128 |
local BUILD_DIR=${bdir%%/}-${impl} |
129 |
export EPYTHON PYTHON |
130 |
|
131 |
-- |
132 |
1.7.12.4 |