/[gentoo-x86]/eclass/python.eclass
Gentoo

Diff of /eclass/python.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.104 Revision 1.105
1# Copyright 1999-2010 Gentoo Foundation 1# Copyright 1999-2010 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.104 2010/10/25 11:54:19 arfrever Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.105 2010/10/29 19:09:08 arfrever Exp $
4 4
5# @ECLASS: python.eclass 5# @ECLASS: python.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# Gentoo Python Project <python@gentoo.org> 7# Gentoo Python Project <python@gentoo.org>
8# @BLURB: Eclass for Python packages 8# @BLURB: Eclass for Python packages
21_PYTHON_SUPPORTED_ABIS=(${_CPYTHON2_SUPPORTED_ABIS[@]} ${_CPYTHON3_SUPPORTED_ABIS[@]} ${_JYTHON_SUPPORTED_ABIS[@]}) 21_PYTHON_SUPPORTED_ABIS=(${_CPYTHON2_SUPPORTED_ABIS[@]} ${_CPYTHON3_SUPPORTED_ABIS[@]} ${_JYTHON_SUPPORTED_ABIS[@]})
22 22
23# ================================================================================================ 23# ================================================================================================
24# ===================================== HANDLING OF METADATA ===================================== 24# ===================================== HANDLING OF METADATA =====================================
25# ================================================================================================ 25# ================================================================================================
26
27_python_set_IUSE() {
28 local PYTHON_ABI restricted_ABI restricted_ABIs support_ABI
29
30 _PYTHON_ABIS_USE_FLAGS=""
31 restricted_ABIs="${RESTRICT_PYTHON_ABIS// /$'\n'}"
32
33 for PYTHON_ABI in "${_PYTHON_SUPPORTED_ABIS[@]}"; do
34 support_ABI="1"
35 while read restricted_ABI; do
36 if [[ "${PYTHON_ABI}" == ${restricted_ABI} ]]; then
37 support_ABI="0"
38 break
39 fi
40 done <<< "${restricted_ABIs}"
41 [[ "${support_ABI}" == "1" ]] && _PYTHON_ABIS_USE_FLAGS+="${_PYTHON_ABIS_USE_FLAGS:+ }python_abis_${PYTHON_ABI}"
42 done
43
44 IUSE="${_PYTHON_ABIS_USE_FLAGS}"
45}
46
47if ! has "${EAPI:-0}" 0 1 2 3 && [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
48 _python_set_IUSE
49fi
50unset -f _python_set_IUSE
51 26
52# @ECLASS-VARIABLE: PYTHON_DEPEND 27# @ECLASS-VARIABLE: PYTHON_DEPEND
53# @DESCRIPTION: 28# @DESCRIPTION:
54# Specification of dependency on dev-lang/python. 29# Specification of dependency on dev-lang/python.
55# Syntax: 30# Syntax:
236 RDEPEND+=" ${_PYTHON_USE_WITH_ATOMS}" 211 RDEPEND+=" ${_PYTHON_USE_WITH_ATOMS}"
237 unset _PYTHON_ATOM _PYTHON_USE_WITH_ATOMS _PYTHON_USE_WITH_ATOMS_ARRAY 212 unset _PYTHON_ATOM _PYTHON_USE_WITH_ATOMS _PYTHON_USE_WITH_ATOMS_ARRAY
238fi 213fi
239 214
240unset _PYTHON_ATOMS 215unset _PYTHON_ATOMS
241
242# @FUNCTION: python_abi_depend
243# @USAGE: [-e|--exclude-ABIs Python_ABIs] [-i|--include-ABIs Python_ABIs] [--] <dependency_atom> [dependency_atoms]
244# @DESCRIPTION:
245# Print dependency atoms with USE dependencies for Python ABIs added.
246# If --exclude-ABIs option is specified, then Python ABIs matching its argument are not used.
247# If --include-ABIs option is specified, then only Python ABIs matching its argument are used.
248# --exclude-ABIs and --include-ABIs options cannot be specified simultaneously.
249python_abi_depend() {
250 local atom atom_index atoms=() exclude_ABIs="0" excluded_ABI excluded_ABIs include_ABIs="0" included_ABI included_ABIs support_ABI USE_dependencies USE_flag USE_flag_index USE_flags=()
251
252 if has "${EAPI:-0}" 0 1 2 3; then
253 die "${FUNCNAME}() cannot be used in this EAPI"
254 fi
255
256 if [[ -z "${SUPPORT_PYTHON_ABIS}" ]]; then
257 die "${FUNCNAME}() cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
258 fi
259
260 while (($#)); do
261 case "$1" in
262 -e|--exclude-ABIs)
263 exclude_ABIs="1"
264 excluded_ABIs="${2// /$'\n'}"
265 shift
266 ;;
267 -i|--include-ABIs)
268 include_ABIs="1"
269 included_ABIs="${2// /$'\n'}"
270 shift
271 ;;
272 --)
273 shift
274 break
275 ;;
276 -*)
277 die "${FUNCNAME}(): Unrecognized option '$1'"
278 ;;
279 *)
280 break
281 ;;
282 esac
283 shift
284 done
285
286 if [[ "${exclude_ABIs}" == "1" && "${include_ABIs}" == "1" ]]; then
287 die "${FUNCNAME}(): '--exclude-ABIs' and '--include-ABIs' options cannot be specified simultaneously"
288 fi
289
290 if [[ "$#" -eq 0 ]]; then
291 die "${FUNCNAME}(): Missing dependency atoms"
292 fi
293
294 atoms=("$@")
295
296 if [[ "${exclude_ABIs}" == "0" && "${include_ABIs}" == "0" ]]; then
297 USE_dependencies="$(printf ",%s?" ${_PYTHON_ABIS_USE_FLAGS})"
298 USE_dependencies="${USE_dependencies#,}"
299
300 for atom_index in "${!atoms[@]}"; do
301 atom="${atoms[${atom_index}]}"
302
303 if [[ "${atom}" == *"["*"]" ]]; then
304 echo -n "${atom%]},"
305 else
306 echo -n "${atom}["
307 fi
308 echo -n "${USE_dependencies}]"
309
310 if [[ "${atom_index}" -ne $((${#atoms[@]} - 1)) ]]; then
311 echo -n " "
312 fi
313 done
314 else
315 if [[ "${exclude_ABIs}" == "1" ]]; then
316 for USE_flag in ${_PYTHON_ABIS_USE_FLAGS}; do
317 while read excluded_ABI; do
318 support_ABI="1"
319 if [[ "${USE_flag}" == python_abis_${excluded_ABI} ]]; then
320 support_ABI="0"
321 break
322 fi
323 done <<< "${excluded_ABIs}"
324 [[ "${support_ABI}" == "1" ]] && USE_flags+=("${USE_flag}")
325 done
326 elif [[ "${include_ABIs}" == "1" ]]; then
327 for USE_flag in ${_PYTHON_ABIS_USE_FLAGS}; do
328 while read included_ABI; do
329 support_ABI="0"
330 if [[ "${USE_flag}" == python_abis_${included_ABI} ]]; then
331 support_ABI="1"
332 break
333 fi
334 done <<< "${included_ABIs}"
335 [[ "${support_ABI}" == "1" ]] && USE_flags+=("${USE_flag}")
336 done
337 else
338 die "${FUNCNAME}(): Internal error"
339 fi
340
341 for USE_flag_index in "${!USE_flags[@]}"; do
342 USE_flag="${USE_flags[${USE_flag_index}]}"
343 USE_dependencies="${USE_flag}"
344
345 echo -n "${USE_flag}? ( "
346
347 for atom_index in "${!atoms[@]}"; do
348 atom="${atoms[${atom_index}]}"
349
350 if [[ "${atom}" == *"["*"]" ]]; then
351 echo -n "${atom%]},"
352 else
353 echo -n "${atom}["
354 fi
355 echo -n "${USE_dependencies}]"
356
357 if [[ "${atom_index}" -ne $((${#atoms[@]} - 1)) ]]; then
358 echo -n " "
359 fi
360 done
361
362 echo -n " )"
363
364 if [[ "${USE_flag_index}" -ne $((${#USE_flags[@]} - 1)) ]]; then
365 echo -n " "
366 fi
367 done
368 fi
369}
370 216
371# ================================================================================================ 217# ================================================================================================
372# =================================== MISCELLANEOUS FUNCTIONS ==================================== 218# =================================== MISCELLANEOUS FUNCTIONS ====================================
373# ================================================================================================ 219# ================================================================================================
374 220

Legend:
Removed from v.1.104  
changed lines
  Added in v.1.105

  ViewVC Help
Powered by ViewVC 1.1.20