1 |
It's based on the PYTHON_SINGLE_TARGET variable concept. For that |
2 |
reason, I used '-single' in the name. If someone could come up with |
3 |
a better name, I'd be happy to use it. |
4 |
|
5 |
It's used on top of python-r1. Similarly, you use ${PYTHON_DEPS} in your |
6 |
RDEP/DEP; [${PYTHON_USEDEP}] can be used to depend on single- and multi- |
7 |
implementation packages. |
8 |
|
9 |
pkg_setup() is exported. It finds the enabled implementation, and |
10 |
exports EPYTHON and PYTHON. |
11 |
|
12 |
You aren't allowed to: |
13 |
|
14 |
1) depend on python-single-r1 packages from python-r1 packages (why |
15 |
would you?), |
16 |
|
17 |
2) use python_foreach_impl() -- it will iterate over all implementations |
18 |
in PYTHON_TARGETS, ignoring PYTHON_SINGLE_TARGET. |
19 |
--- |
20 |
gx86/eclass/python-single-r1.eclass | 93 +++++++++++++++++++++++++++++++++++++ |
21 |
1 file changed, 93 insertions(+) |
22 |
create mode 100644 gx86/eclass/python-single-r1.eclass |
23 |
|
24 |
diff --git a/gx86/eclass/python-single-r1.eclass b/gx86/eclass/python-single-r1.eclass |
25 |
new file mode 100644 |
26 |
index 0000000..3d21ea8 |
27 |
--- /dev/null |
28 |
+++ b/gx86/eclass/python-single-r1.eclass |
29 |
@@ -0,0 +1,93 @@ |
30 |
+# Copyright 1999-2012 Gentoo Foundation |
31 |
+# Distributed under the terms of the GNU General Public License v2 |
32 |
+# $Header: /var/cvsroot/gentoo-x86/eclass/python-r1.eclass,v 1.20 2012/11/21 09:04:14 mgorny Exp $ |
33 |
+ |
34 |
+# @ECLASS: python-single-r1 |
35 |
+# @MAINTAINER: |
36 |
+# Michał Górny <mgorny@g.o> |
37 |
+# Python herd <python@g.o> |
38 |
+# @AUTHOR: |
39 |
+# Author: Michał Górny <mgorny@g.o> |
40 |
+# Based on work of: Krzysztof Pawlik <nelchael@g.o> |
41 |
+# @BLURB: An eclass for Python packages not installed for multiple implementations. |
42 |
+# @DESCRIPTION: |
43 |
+# An extension of the python-r1 eclass suite for packages which |
44 |
+# don't support being installed for multiple Python implementations. |
45 |
+# This mostly includes tools embedding Python. |
46 |
+# |
47 |
+# This eclass extends the IUSE and REQUIRED_USE set by python-r1 |
48 |
+# to request correct PYTHON_SINGLE_TARGET. It also replaces |
49 |
+# PYTHON_USEDEP and PYTHON_DEPS with a more suitable form. |
50 |
+# |
51 |
+# Please note that packages support multiple Python implementations |
52 |
+# (using python-r1 eclass) can not depend on packages not supporting |
53 |
+# them (using this eclass). |
54 |
+# |
55 |
+# Also, please note that python-single-r1 will always inherit python-r1 |
56 |
+# as well. Thus, all the variables defined and documented there are |
57 |
+# relevant to the packages using python-single-r1. |
58 |
+ |
59 |
+case "${EAPI}" in |
60 |
+ 0|1|2|3) |
61 |
+ die "Unsupported EAPI=${EAPI} (too old) for ${ECLASS}" |
62 |
+ ;; |
63 |
+ 4|5) |
64 |
+ # EAPI=4 needed by python-r1 |
65 |
+ ;; |
66 |
+ *) |
67 |
+ die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}" |
68 |
+ ;; |
69 |
+esac |
70 |
+ |
71 |
+inherit python-r1 |
72 |
+ |
73 |
+EXPORT_FUNCTIONS pkg_setup |
74 |
+ |
75 |
+_python_single_set_globals() { |
76 |
+ local flags=( "${PYTHON_COMPAT[@]/#/python_single_target_}" ) |
77 |
+ local optflags=${flags[@]/%/(+)?} |
78 |
+ |
79 |
+ IUSE=${flags[*]} |
80 |
+ REQUIRED_USE="^^ ( ${flags[*]} )" |
81 |
+ PYTHON_USEDEP+=,${optflags// /,} |
82 |
+ |
83 |
+ local usestr |
84 |
+ [[ ${PYTHON_REQ_USE} ]] && usestr="[${PYTHON_REQ_USE}]" |
85 |
+ |
86 |
+ # 1) well, python-exec would suffice as an RDEP |
87 |
+ # but no point in making this overcomplex, BDEP doesn't hurt anyone |
88 |
+ # 2) python-exec should be built with all targets forced anyway |
89 |
+ # but if new targets were added, we may need to force a rebuild |
90 |
+ PYTHON_DEPS="dev-python/python-exec[${PYTHON_USEDEP}]" |
91 |
+ local i |
92 |
+ for i in "${PYTHON_COMPAT[@]}"; do |
93 |
+ local d |
94 |
+ case ${i} in |
95 |
+ python*) |
96 |
+ d='dev-lang/python';; |
97 |
+ jython*) |
98 |
+ d='dev-java/jython';; |
99 |
+ pypy*) |
100 |
+ d='dev-python/pypy';; |
101 |
+ *) |
102 |
+ die "Invalid implementation: ${i}" |
103 |
+ esac |
104 |
+ |
105 |
+ local v=${i##*[a-z]} |
106 |
+ PYTHON_DEPS+=" python_single_target_${i}? ( ${d}:${v/_/.}${usestr} )" |
107 |
+ done |
108 |
+} |
109 |
+_python_single_set_globals |
110 |
+ |
111 |
+python-single-r1_pkg_setup() { |
112 |
+ debug-print-function ${FUNCNAME} "${@}" |
113 |
+ |
114 |
+ for impl in "${_PYTHON_ALL_IMPLS[@]}"; do |
115 |
+ if has "${impl}" "${PYTHON_COMPAT[@]}" \ |
116 |
+ && use "python_single_target_${impl}" |
117 |
+ then |
118 |
+ python_export "${impl}" EPYTHON PYTHON |
119 |
+ break |
120 |
+ fi |
121 |
+ done |
122 |
+} |
123 |
-- |
124 |
1.8.0 |