1 |
This eclass handles the build-time-only dependencies on Python. It adds |
2 |
a one-of dep and finds the best interpreter installed. |
3 |
--- |
4 |
gx86/eclass/python-build-r1.eclass | 172 ++++++++++++++++++++++++++++++++++++ |
5 |
gx86/eclass/python-r1.eclass | 2 + |
6 |
gx86/eclass/python-single-r1.eclass | 2 + |
7 |
3 files changed, 176 insertions(+) |
8 |
create mode 100644 gx86/eclass/python-build-r1.eclass |
9 |
|
10 |
diff --git a/gx86/eclass/python-build-r1.eclass b/gx86/eclass/python-build-r1.eclass |
11 |
new file mode 100644 |
12 |
index 0000000..d5d1ce0 |
13 |
--- /dev/null |
14 |
+++ b/gx86/eclass/python-build-r1.eclass |
15 |
@@ -0,0 +1,172 @@ |
16 |
+# Copyright 1999-2012 Gentoo Foundation |
17 |
+# Distributed under the terms of the GNU General Public License v2 |
18 |
+# $Header: /var/cvsroot/gentoo-x86/eclass/python-single-r1.eclass,v 1.4 2012/11/26 10:05:11 mgorny Exp $ |
19 |
+ |
20 |
+# @ECLASS: python-build-r1 |
21 |
+# @MAINTAINER: |
22 |
+# Michał Górny <mgorny@g.o> |
23 |
+# Python herd <python@g.o> |
24 |
+# @AUTHOR: |
25 |
+# Author: Michał Górny <mgorny@g.o> |
26 |
+# Based on work of: Krzysztof Pawlik <nelchael@g.o> |
27 |
+# @BLURB: An eclass for packages having build-time dependency on Python. |
28 |
+# @DESCRIPTION: |
29 |
+# A minimal eclass for packages which need to use the Python interpreter |
30 |
+# at build-time but have no other relevance to Python. |
31 |
+# |
32 |
+# This eclass provides a minimal PYTHON_DEPS variable with a dependency |
33 |
+# string on any of the supported Python implementations. It also exports |
34 |
+# pkg_setup() which finds the best supported implementation and sets it |
35 |
+# as the active one. |
36 |
+# |
37 |
+# Please note that python-build-r1 will always inherit python-utils-r1 |
38 |
+# as well. Thus, all the functions defined there can be used in the |
39 |
+# packages using python-build-r1, and there is no need ever to inherit |
40 |
+# both. |
41 |
+# |
42 |
+# For more information, please see the python-r1 Developer's Guide: |
43 |
+# http://www.gentoo.org/proj/en/Python/python-r1/dev-guide.xml |
44 |
+ |
45 |
+case "${EAPI:-0}" in |
46 |
+ 0|1|2|3|4|5) |
47 |
+ # EAPI=4 needed by python-r1 |
48 |
+ ;; |
49 |
+ *) |
50 |
+ die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}" |
51 |
+ ;; |
52 |
+esac |
53 |
+ |
54 |
+if [[ ! ${_PYTHON_BUILD_R1} ]]; then |
55 |
+ |
56 |
+if [[ ${_PYTHON_R1} ]]; then |
57 |
+ die 'python-build-r1.eclass can not be used with python-r1.eclass.' |
58 |
+elif [[ ${_PYTHON_SINGLE_R1} ]]; then |
59 |
+ die 'python-build-r1.eclass can not be used with python-single-r1.eclass.' |
60 |
+fi |
61 |
+ |
62 |
+inherit python-utils-r1 |
63 |
+ |
64 |
+fi |
65 |
+ |
66 |
+EXPORT_FUNCTIONS pkg_setup |
67 |
+ |
68 |
+if [[ ! ${_PYTHON_BUILD_R1} ]]; then |
69 |
+ |
70 |
+# @ECLASS-VARIABLE: PYTHON_COMPAT |
71 |
+# @REQUIRED |
72 |
+# @DESCRIPTION: |
73 |
+# This variable contains a list of Python implementations the package |
74 |
+# supports. It must be set before the `inherit' call. It has to be |
75 |
+# an array. |
76 |
+# |
77 |
+# Example: |
78 |
+# @CODE |
79 |
+# PYTHON_COMPAT=( python{2_5,2_6,2_7} ) |
80 |
+# @CODE |
81 |
+if ! declare -p PYTHON_COMPAT &>/dev/null; then |
82 |
+ die 'PYTHON_COMPAT not declared.' |
83 |
+fi |
84 |
+ |
85 |
+# @ECLASS-VARIABLE: PYTHON_REQ_USE |
86 |
+# @DEFAULT_UNSET |
87 |
+# @DESCRIPTION: |
88 |
+# The list of USEflags required to be enabled on the Python |
89 |
+# implementations, formed as a USE-dependency string. It should be valid |
90 |
+# for all implementations in PYTHON_COMPAT, so it may be necessary to |
91 |
+# use USE defaults. |
92 |
+# |
93 |
+# Example: |
94 |
+# @CODE |
95 |
+# PYTHON_REQ_USE="gdbm,ncurses(-)?" |
96 |
+# @CODE |
97 |
+# |
98 |
+# It will cause the Python dependencies to look like: |
99 |
+# @CODE |
100 |
+# || ( dev-lang/python:X.Y[gdbm,ncurses(-)?] ... ) |
101 |
+# @CODE |
102 |
+ |
103 |
+# @ECLASS-VARIABLE: PYTHON_DEPS |
104 |
+# @DESCRIPTION: |
105 |
+# This is an eclass-generated Python dependency string for all |
106 |
+# implementations listed in PYTHON_COMPAT. |
107 |
+# |
108 |
+# Any of the supported interpreters will satisfy the dependency. |
109 |
+# |
110 |
+# Example use: |
111 |
+# @CODE |
112 |
+# DEPEND="${RDEPEND} |
113 |
+# ${PYTHON_DEPS}" |
114 |
+# @CODE |
115 |
+# |
116 |
+# Example value: |
117 |
+# @CODE |
118 |
+# || ( dev-lang/python:2.7[gdbm] |
119 |
+# dev-lang/python:2.6[gdbm] ) |
120 |
+# @CODE |
121 |
+ |
122 |
+_python_build_set_globals() { |
123 |
+ local usestr |
124 |
+ [[ ${PYTHON_REQ_USE} ]] && usestr="[${PYTHON_REQ_USE}]" |
125 |
+ |
126 |
+ PYTHON_DEPS= |
127 |
+ local i |
128 |
+ for i in "${_PYTHON_ALL_IMPLS[@]}"; do |
129 |
+ if has "${i}" "${PYTHON_COMPAT[@]}" |
130 |
+ then |
131 |
+ local d |
132 |
+ case ${i} in |
133 |
+ python*) |
134 |
+ d='dev-lang/python';; |
135 |
+ jython*) |
136 |
+ d='dev-java/jython';; |
137 |
+ pypy*) |
138 |
+ d='dev-python/pypy';; |
139 |
+ *) |
140 |
+ die "Invalid implementation: ${i}" |
141 |
+ esac |
142 |
+ |
143 |
+ local v=${i##*[a-z]} |
144 |
+ PYTHON_DEPS="${d}:${v/_/.}${usestr} ${PYTHON_DEPS}" |
145 |
+ fi |
146 |
+ done |
147 |
+ PYTHON_DEPS="|| ( ${PYTHON_DEPS})" |
148 |
+} |
149 |
+_python_build_set_globals |
150 |
+ |
151 |
+# @FUNCTION: python-single-r1_pkg_setup |
152 |
+# @DESCRIPTION: |
153 |
+# Determine what the best installed (and supported) Python |
154 |
+# implementation is and set EPYTHON and PYTHON accordingly. |
155 |
+python-build-r1_pkg_setup() { |
156 |
+ debug-print-function ${FUNCNAME} "${@}" |
157 |
+ |
158 |
+ local i rev_impls=() |
159 |
+ for i in "${_PYTHON_ALL_IMPLS[@]}"; do |
160 |
+ if has "${i}" "${PYTHON_COMPAT[@]}"; then |
161 |
+ rev_impls=( "${i}" "${rev_impls[@]}" ) |
162 |
+ fi |
163 |
+ done |
164 |
+ |
165 |
+ for i in "${rev_impls[@]}"; do |
166 |
+ local d |
167 |
+ case "${i}" in |
168 |
+ python*) |
169 |
+ d='dev-lang/python';; |
170 |
+ jython*) |
171 |
+ d='dev-java/jython';; |
172 |
+ pypy*) |
173 |
+ d='dev-python/pypy';; |
174 |
+ *) |
175 |
+ die "Invalid implementation: ${i}" |
176 |
+ esac |
177 |
+ local v=${i##*[a-z]} |
178 |
+ |
179 |
+ if has_version "${d}:${v/_/.}${usestr}"; then |
180 |
+ python_export "${i}" EPYTHON PYTHON |
181 |
+ break |
182 |
+ fi |
183 |
+ done |
184 |
+} |
185 |
+ |
186 |
+_PYTHON_BUILD_R1=1 |
187 |
+fi |
188 |
diff --git a/gx86/eclass/python-r1.eclass b/gx86/eclass/python-r1.eclass |
189 |
index c8cfef3..0f62473 100644 |
190 |
--- a/gx86/eclass/python-r1.eclass |
191 |
+++ b/gx86/eclass/python-r1.eclass |
192 |
@@ -44,6 +44,8 @@ if [[ ! ${_PYTHON_R1} ]]; then |
193 |
|
194 |
if [[ ${_PYTHON_SINGLE_R1} ]]; then |
195 |
die 'python-r1.eclass can not be used with python-single-r1.eclass.' |
196 |
+elif [[ ${_PYTHON_BUILD_R1} ]]; then |
197 |
+ die 'python-r1.eclass can not be used with python-build-r1.eclass.' |
198 |
fi |
199 |
|
200 |
inherit python-utils-r1 |
201 |
diff --git a/gx86/eclass/python-single-r1.eclass b/gx86/eclass/python-single-r1.eclass |
202 |
index f645513..60c9977 100644 |
203 |
--- a/gx86/eclass/python-single-r1.eclass |
204 |
+++ b/gx86/eclass/python-single-r1.eclass |
205 |
@@ -47,6 +47,8 @@ if [[ ! ${_PYTHON_SINGLE_R1} ]]; then |
206 |
|
207 |
if [[ ${_PYTHON_R1} ]]; then |
208 |
die 'python-single-r1.eclass can not be used with python-r1.eclass.' |
209 |
+elif [[ ${_PYTHON_BUILD_R1} ]]; then |
210 |
+ die 'python-single-r1.eclass can not be used with python-build-r1.eclass.' |
211 |
fi |
212 |
|
213 |
inherit python-utils-r1 |
214 |
-- |
215 |
1.8.0 |