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

Contents of /eclass/python-single-r1.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download)
Sat Nov 24 21:07:14 2012 UTC (19 months, 2 weeks ago) by mgorny
Branch: MAIN
Changes since 1.1: +9 -3 lines
Fix EAPI checks, add double- and colliding include guards.

1 # Copyright 1999-2012 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/python-single-r1.eclass,v 1.1 2012/11/24 20:53:53 mgorny Exp $
4
5 # @ECLASS: python-single-r1
6 # @MAINTAINER:
7 # Michał Górny <mgorny@gentoo.org>
8 # Python herd <python@gentoo.org>
9 # @AUTHOR:
10 # Author: Michał Górny <mgorny@gentoo.org>
11 # Based on work of: Krzysztof Pawlik <nelchael@gentoo.org>
12 # @BLURB: An eclass for Python packages not installed for multiple implementations.
13 # @DESCRIPTION:
14 # An extension of the python-r1 eclass suite for packages which
15 # don't support being installed for multiple Python implementations.
16 # This mostly includes tools embedding Python.
17 #
18 # This eclass extends the IUSE and REQUIRED_USE set by python-r1
19 # to request correct PYTHON_SINGLE_TARGET. It also replaces
20 # PYTHON_USEDEP and PYTHON_DEPS with a more suitable form.
21 #
22 # Please note that packages support multiple Python implementations
23 # (using python-r1 eclass) can not depend on packages not supporting
24 # them (using this eclass).
25 #
26 # Also, please note that python-single-r1 will always inherit python-r1
27 # as well. Thus, all the variables defined there are relevant
28 # to the packages using python-single-r1.
29 #
30 # For more information, please see the python-r1 Developer's Guide:
31 # http://www.gentoo.org/proj/en/Python/python-r1/dev-guide.xml
32
33 case "${EAPI:-0}" in
34 0|1|2|3)
35 die "Unsupported EAPI=${EAPI:-0} (too old) for ${ECLASS}"
36 ;;
37 4|5)
38 # EAPI=4 needed by python-r1
39 ;;
40 *)
41 die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}"
42 ;;
43 esac
44
45 if [[ ! ${_PYTHON_SINGLE_R1} ]]; then
46
47 inherit python-r1
48
49 EXPORT_FUNCTIONS pkg_setup
50
51 _python_single_set_globals() {
52 local flags=( "${PYTHON_COMPAT[@]/#/python_single_target_}" )
53 local optflags=${flags[@]/%/(+)?}
54
55 IUSE=${flags[*]}
56 REQUIRED_USE="^^ ( ${flags[*]} )"
57 PYTHON_USEDEP+=,${optflags// /,}
58
59 local usestr
60 [[ ${PYTHON_REQ_USE} ]] && usestr="[${PYTHON_REQ_USE}]"
61
62 # 1) well, python-exec would suffice as an RDEP
63 # but no point in making this overcomplex, BDEP doesn't hurt anyone
64 # 2) python-exec should be built with all targets forced anyway
65 # but if new targets were added, we may need to force a rebuild
66 PYTHON_DEPS="dev-python/python-exec[${PYTHON_USEDEP}]"
67 local i
68 for i in "${PYTHON_COMPAT[@]}"; do
69 local d
70 case ${i} in
71 python*)
72 d='dev-lang/python';;
73 jython*)
74 d='dev-java/jython';;
75 pypy*)
76 d='dev-python/pypy';;
77 *)
78 die "Invalid implementation: ${i}"
79 esac
80
81 local v=${i##*[a-z]}
82 PYTHON_DEPS+=" python_single_target_${i}? ( ${d}:${v/_/.}${usestr} )"
83 done
84 }
85 _python_single_set_globals
86
87 python-single-r1_pkg_setup() {
88 debug-print-function ${FUNCNAME} "${@}"
89
90 local impl
91 for impl in "${_PYTHON_ALL_IMPLS[@]}"; do
92 if has "${impl}" "${PYTHON_COMPAT[@]}" \
93 && use "python_single_target_${impl}"
94 then
95 python_export "${impl}" EPYTHON PYTHON
96 break
97 fi
98 done
99 }
100
101 _PYTHON_SINGLE_R1=1
102 fi

  ViewVC Help
Powered by ViewVC 1.1.20