1 |
arfrever 09/10/02 02:02:24 |
2 |
|
3 |
Modified: python.eclass |
4 |
Log: |
5 |
Automatically enable Python 2 and Python 3 if no version has been explicitly enabled. Improve python_pkg_setup(). |
6 |
|
7 |
Revision Changes Path |
8 |
1.74 eclass/python.eclass |
9 |
|
10 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.74&view=markup |
11 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.74&content-type=text/plain |
12 |
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.73&r2=1.74 |
13 |
|
14 |
Index: python.eclass |
15 |
=================================================================== |
16 |
RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v |
17 |
retrieving revision 1.73 |
18 |
retrieving revision 1.74 |
19 |
diff -u -r1.73 -r1.74 |
20 |
--- python.eclass 18 Sep 2009 17:50:08 -0000 1.73 |
21 |
+++ python.eclass 2 Oct 2009 02:02:24 -0000 1.74 |
22 |
@@ -1,11 +1,11 @@ |
23 |
# Copyright 1999-2009 Gentoo Foundation |
24 |
# Distributed under the terms of the GNU General Public License v2 |
25 |
-# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.73 2009/09/18 17:50:08 arfrever Exp $ |
26 |
+# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.74 2009/10/02 02:02:24 arfrever Exp $ |
27 |
|
28 |
# @ECLASS: python.eclass |
29 |
# @MAINTAINER: |
30 |
# python@g.o |
31 |
-# @BLURB: A Utility Eclass that should be inherited by anything that deals with Python or Python modules. |
32 |
+# @BLURB: A utility eclass that should be inherited by anything that deals with Python or Python modules. |
33 |
# @DESCRIPTION: |
34 |
# Some useful functions for dealing with Python. |
35 |
|
36 |
@@ -19,10 +19,8 @@ |
37 |
PYTHON_ATOM="dev-lang/python" |
38 |
fi |
39 |
|
40 |
-DEPEND="${DEPEND} >=app-shells/bash-3.2" |
41 |
-if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then |
42 |
- DEPEND="${DEPEND} >=app-admin/eselect-python-20090804" |
43 |
-fi |
44 |
+DEPEND+=" >=app-admin/eselect-python-20090804 |
45 |
+ >=app-shells/bash-3.2" |
46 |
|
47 |
__python_eclass_test() { |
48 |
__python_version_extract 2.3 |
49 |
@@ -129,7 +127,7 @@ |
50 |
|
51 |
# USE_${ABI_TYPE^^} and RESTRICT_${ABI_TYPE^^}_ABIS variables hopefully will be included in EAPI >= 4. |
52 |
if [[ "$(declare -p PYTHON_ABIS 2> /dev/null)" != "declare -x PYTHON_ABIS="* ]] && has "${EAPI:-0}" 0 1 2 3; then |
53 |
- local ABI support_ABI supported_PYTHON_ABIS= restricted_ABI |
54 |
+ local ABI restricted_ABI support_ABI supported_PYTHON_ABIS= |
55 |
PYTHON_ABI_SUPPORTED_VALUES="2.4 2.5 2.6 2.7 3.0 3.1 3.2" |
56 |
|
57 |
if [[ "$(declare -p USE_PYTHON 2> /dev/null)" == "declare -x USE_PYTHON="* ]]; then |
58 |
@@ -153,18 +151,70 @@ |
59 |
export PYTHON_ABIS="${supported_PYTHON_ABIS# }" |
60 |
|
61 |
if [[ -z "${PYTHON_ABIS//[${IFS}]/}" ]]; then |
62 |
- die "USE_PYTHON variable doesn't enable any Python version supported by ${CATEGORY}/${PF}" |
63 |
+ die "USE_PYTHON variable doesn't enable any version of Python supported by ${CATEGORY}/${PF}" |
64 |
fi |
65 |
else |
66 |
- local restricted_ABI |
67 |
- python_version |
68 |
+ local ABI python2_version= python2_supported_versions python3_version= python3_supported_versions restricted_ABI support_python_major_version |
69 |
|
70 |
- for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do |
71 |
- if python -c "from fnmatch import fnmatch; exit(not fnmatch('${PYVER}', '${restricted_ABI}'))"; then |
72 |
- die "Active Python version isn't supported by ${CATEGORY}/${PF}" |
73 |
+ if has_version "=dev-lang/python-2*"; then |
74 |
+ if [[ "$(readlink /usr/bin/python2)" != "python2."* ]]; then |
75 |
+ die "'/usr/bin/python2' isn't valid symlink" |
76 |
fi |
77 |
- done |
78 |
- export PYTHON_ABIS="${PYVER}" |
79 |
+ |
80 |
+ python2_version="$(/usr/bin/python2 -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')" |
81 |
+ python2_supported_versions="2.4 2.5 2.6 2.7" |
82 |
+ |
83 |
+ for ABI in ${python2_supported_versions}; do |
84 |
+ support_python_major_version="1" |
85 |
+ for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do |
86 |
+ if python -c "from fnmatch import fnmatch; exit(not fnmatch('${ABI}', '${restricted_ABI}'))"; then |
87 |
+ support_python_major_version="0" |
88 |
+ fi |
89 |
+ done |
90 |
+ [[ "${support_python_major_version}" == "1" ]] && break |
91 |
+ done |
92 |
+ if [[ "${support_python_major_version}" == "1" ]]; then |
93 |
+ for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do |
94 |
+ if python -c "from fnmatch import fnmatch; exit(not fnmatch('${python2_version}', '${restricted_ABI}'))"; then |
95 |
+ die "Active version of Python 2 isn't supported by ${CATEGORY}/${PF}" |
96 |
+ fi |
97 |
+ done |
98 |
+ else |
99 |
+ python2_version="" |
100 |
+ fi |
101 |
+ fi |
102 |
+ |
103 |
+ if has_version "=dev-lang/python-3*"; then |
104 |
+ if [[ "$(readlink /usr/bin/python3)" != "python3."* ]]; then |
105 |
+ die "'/usr/bin/python3' isn't valid symlink" |
106 |
+ fi |
107 |
+ |
108 |
+ python3_version="$(/usr/bin/python3 -c 'from sys import version_info; print(".".join([str(x) for x in version_info[:2]]))')" |
109 |
+ python3_supported_versions="3.0 3.1 3.2" |
110 |
+ |
111 |
+ for ABI in ${python3_supported_versions}; do |
112 |
+ support_python_major_version="1" |
113 |
+ for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do |
114 |
+ if python -c "from fnmatch import fnmatch; exit(not fnmatch('${ABI}', '${restricted_ABI}'))"; then |
115 |
+ support_python_major_version="0" |
116 |
+ fi |
117 |
+ done |
118 |
+ [[ "${support_python_major_version}" == "1" ]] && break |
119 |
+ done |
120 |
+ if [[ "${support_python_major_version}" == "1" ]]; then |
121 |
+ for restricted_ABI in ${RESTRICT_PYTHON_ABIS}; do |
122 |
+ if python -c "from fnmatch import fnmatch; exit(not fnmatch('${python3_version}', '${restricted_ABI}'))"; then |
123 |
+ die "Active version of Python 3 isn't supported by ${CATEGORY}/${PF}" |
124 |
+ fi |
125 |
+ done |
126 |
+ else |
127 |
+ python3_version="" |
128 |
+ fi |
129 |
+ fi |
130 |
+ |
131 |
+ PYTHON_ABIS="${python2_version} ${python3_version}" |
132 |
+ PYTHON_ABIS="${PYTHON_ABIS# }" |
133 |
+ export PYTHON_ABIS="${PYTHON_ABIS% }" |
134 |
fi |
135 |
fi |
136 |
|
137 |
@@ -475,55 +525,64 @@ |
138 |
# Makes sure PYTHON_USE_WITH or PYTHON_USE_WITH_OR listed use flags |
139 |
# are respected. Only exported if one of those variables is set. |
140 |
if ! has "${EAPI:-0}" 0 1 && [[ -n ${PYTHON_USE_WITH} || -n ${PYTHON_USE_WITH_OR} ]]; then |
141 |
- python_pkg_setup_fail() { |
142 |
- eerror "${1}" |
143 |
- die "${1}" |
144 |
- } |
145 |
- |
146 |
python_pkg_setup() { |
147 |
- [[ ${PYTHON_USE_WITH_OPT} ]] && use !${PYTHON_USE_WITH_OPT} && return |
148 |
+ python_pkg_setup_fail() { |
149 |
+ eerror "${1}" |
150 |
+ die "${1}" |
151 |
+ } |
152 |
|
153 |
- python_version |
154 |
- local failed |
155 |
- local pyatom="dev-lang/python:${PYVER}" |
156 |
+ [[ ${PYTHON_USE_WITH_OPT} ]] && use !${PYTHON_USE_WITH_OPT} && return |
157 |
|
158 |
- for use in ${PYTHON_USE_WITH}; do |
159 |
- if ! has_version "${pyatom}[${use}]"; then |
160 |
- python_pkg_setup_fail \ |
161 |
- "Please rebuild ${pyatom} with use flags: ${PYTHON_USE_WITH}" |
162 |
+ python_pkg_setup_check_USE_flags() { |
163 |
+ local pyatom use |
164 |
+ if [[ -n "${PYTHON_ABI}" ]]; then |
165 |
+ pyatom="dev-lang/python:${PYTHON_ABI}" |
166 |
+ else |
167 |
+ python_version |
168 |
+ pyatom="dev-lang/python:${PYVER}" |
169 |
fi |
170 |
- done |
171 |
|
172 |
- for use in ${PYTHON_USE_WITH_OR}; do |
173 |
- if has_version "${pyatom}[${use}]"; then |
174 |
- return |
175 |
+ for use in ${PYTHON_USE_WITH}; do |
176 |
+ if ! has_version "${pyatom}[${use}]"; then |
177 |
+ python_pkg_setup_fail "Please rebuild ${pyatom} with the following USE flags enabled: ${PYTHON_USE_WITH}" |
178 |
+ fi |
179 |
+ done |
180 |
+ |
181 |
+ for use in ${PYTHON_USE_WITH_OR}; do |
182 |
+ if has_version "${pyatom}[${use}]"; then |
183 |
+ return |
184 |
+ fi |
185 |
+ done |
186 |
+ |
187 |
+ if [[ ${PYTHON_USE_WITH_OR} ]]; then |
188 |
+ python_pkg_setup_fail "Please rebuild ${pyatom} with at least one of the following USE flags enabled: ${PYTHON_USE_WITH_OR}" |
189 |
fi |
190 |
- done |
191 |
+ } |
192 |
|
193 |
- if [[ ${PYTHON_USE_WITH_OR} ]]; then |
194 |
- python_pkg_setup_fail \ |
195 |
- "Please rebuild ${pyatom} with one of: ${PYTHON_USE_WITH_OR}" |
196 |
+ if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then |
197 |
+ python_execute_function -q python_pkg_setup_check_USE_flags |
198 |
+ else |
199 |
+ python_pkg_setup_check_USE_flags |
200 |
fi |
201 |
} |
202 |
|
203 |
EXPORT_FUNCTIONS pkg_setup |
204 |
|
205 |
- if [[ ${PYTHON_USE_WITH} ]]; then |
206 |
+ if [[ -n "${PYTHON_USE_WITH}" ]]; then |
207 |
PYTHON_USE_WITH_ATOM="${PYTHON_ATOM}[${PYTHON_USE_WITH/ /,}]" |
208 |
- elif [[ ${PYTHON_USE_WITH_OR} ]]; then |
209 |
+ elif [[ -n "${PYTHON_USE_WITH_OR}" ]]; then |
210 |
PYTHON_USE_WITH_ATOM="|| ( " |
211 |
for use in ${PYTHON_USE_WITH_OR}; do |
212 |
- PYTHON_USE_WITH_ATOM=" |
213 |
- ${PYTHON_USE_WITH_ATOM} |
214 |
- ${PYTHON_ATOM}[${use}]" |
215 |
+ PYTHON_USE_WITH_ATOM+=" ${PYTHON_ATOM}[${use}]" |
216 |
done |
217 |
- PYTHON_USE_WITH_ATOM="${PYTHON_USE_WITH_ATOM} )" |
218 |
+ unset use |
219 |
+ PYTHON_USE_WITH_ATOM+=" )" |
220 |
fi |
221 |
- if [[ ${PYTHON_USE_WITH_OPT} ]]; then |
222 |
+ if [[ -n "${PYTHON_USE_WITH_OPT}" ]]; then |
223 |
PYTHON_USE_WITH_ATOM="${PYTHON_USE_WITH_OPT}? ( ${PYTHON_USE_WITH_ATOM} )" |
224 |
fi |
225 |
- DEPEND="${PYTHON_USE_WITH_ATOM}" |
226 |
- RDEPEND="${PYTHON_USE_WITH_ATOM}" |
227 |
+ DEPEND+=" ${PYTHON_USE_WITH_ATOM}" |
228 |
+ RDEPEND+=" ${PYTHON_USE_WITH_ATOM}" |
229 |
fi |
230 |
|
231 |
# @ECLASS-VARIABLE: PYTHON_DEFINE_DEFAULT_FUNCTIONS |