Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH 5/6] Move PYTHON_COMPAT, IUSE and REQUIRED_USE to python-r1.
Date: Wed, 19 Sep 2012 10:05:42
Message-Id: 1348048827-1290-5-git-send-email-mgorny@gentoo.org
In Reply to: [gentoo-dev] [PATCH 1/6] Drop pointless default S assignment. by "Michał Górny"
1 ---
2 gx86/eclass/python-distutils-ng.eclass | 31 ++------------------
3 gx86/eclass/python-r1.eclass | 53 ++++++++++++++++++++++++++++++++++
4 2 files changed, 55 insertions(+), 29 deletions(-)
5 create mode 100644 gx86/eclass/python-r1.eclass
6
7 diff --git a/gx86/eclass/python-distutils-ng.eclass b/gx86/eclass/python-distutils-ng.eclass
8 index edc38a4..5df965c 100644
9 --- a/gx86/eclass/python-distutils-ng.eclass
10 +++ b/gx86/eclass/python-distutils-ng.eclass
11 @@ -26,26 +26,6 @@
12 # each implementation and python_install_all that will be run in original
13 # directory (so it will not contain any implementation-specific files)
14
15 -# @ECLASS-VARIABLE: PYTHON_COMPAT
16 -# @DEFAULT_UNSET
17 -# @DESCRIPTION:
18 -# This variable contains a space separated list of implementations (see above) a
19 -# package is compatible to. It must be set before the `inherit' call. The
20 -# default is to enable all implementations.
21 -#
22 -# PYTHON_COMPAT can be either a scalar or an array. If it's a scalar, the eclass
23 -# will implicitly convert it to an array.
24 -
25 -if [[ -z "${PYTHON_COMPAT}" ]]; then
26 - # Default: pure python, support all implementations
27 - PYTHON_COMPAT=" python2_5 python2_6 python2_7"
28 - PYTHON_COMPAT+=" python3_1 python3_2"
29 - PYTHON_COMPAT+=" jython2_5"
30 - PYTHON_COMPAT+=" pypy1_8 pypy1_9"
31 -fi
32 -
33 -PYTHON_COMPAT=( ${PYTHON_COMPAT[@]} )
34 -
35 # @ECLASS-VARIABLE: PYTHON_DISABLE_COMPILATION
36 # @DEFAULT_UNSET
37 # @DESCRIPTION:
38 @@ -68,6 +48,8 @@ case "${EAPI}" in
39 die "Unsupported EAPI=${EAPI} (unknown) for python-distutils-ng.eclass" ;;
40 esac
41
42 +inherit python-r1
43 +
44 EXPORT_FUNCTIONS src_prepare src_configure src_compile src_test src_install
45
46 DEPEND="${DEPEND} !<sys-apps/portage-2.1.10.58"
47 @@ -92,16 +74,7 @@ _python-distutils-ng_get_binary_for_implementation() {
48 esac
49 }
50
51 -required_use_str=""
52 -for impl in ${PYTHON_COMPAT[@]}; do
53 - required_use_str+=" python_targets_${impl}"
54 -done
55 -required_use_str=" || ( ${required_use_str} )"
56 -REQUIRED_USE+=" ${required_use_str}"
57 -unset required_use_str
58 -
59 for impl in ${PYTHON_COMPAT[@]}; do
60 - IUSE+=" python_targets_${impl}"
61 dep_str="${impl/_/.}"
62 case "${dep_str}" in
63 python?.?)
64 diff --git a/gx86/eclass/python-r1.eclass b/gx86/eclass/python-r1.eclass
65 new file mode 100644
66 index 0000000..18f9246
67 --- /dev/null
68 +++ b/gx86/eclass/python-r1.eclass
69 @@ -0,0 +1,53 @@
70 +# Copyright 1999-2012 Gentoo Foundation
71 +# Distributed under the terms of the GNU General Public License v2
72 +# $Header: $
73 +
74 +# @ECLASS: python-r1
75 +# @MAINTAINER:
76 +# Python herd <python@g.o>
77 +# @AUTHOR:
78 +# Author: Michał Górny <mgorny@g.o>
79 +# Based on work of: Krzysztof Pawlik <nelchael@g.o>
80 +# @BLURB: A common eclass for Python packages supporting multiple ABIs.
81 +# @DESCRIPTION:
82 +
83 +case "${EAPI}" in
84 + 0|1|2|3)
85 + die "Unsupported EAPI=${EAPI} (too old) for ${ECLASS}"
86 + ;;
87 + 4)
88 + # EAPI=4 needed for REQUIRED_USE
89 + ;;
90 + *)
91 + die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}"
92 + ;;
93 +esac
94 +
95 +# @ECLASS-VARIABLE: _PYTHON_ALL_IMPLS
96 +# @INTERNAL
97 +# @DESCRIPTION:
98 +# All supported Python implementations, most preferred first.
99 +_PYTHON_ALL_IMPLS=(
100 + python2_7 python2_6 python2_5
101 + python3_2 python3_1
102 + pypy1_9 pypy1_8
103 + jython2_5
104 +)
105 +
106 +# @ECLASS-VARIABLE: PYTHON_COMPAT
107 +# @DESCRIPTION:
108 +# This variable contains a space separated list of Pythonimplementations
109 +# a package supports. It must be set before the `inherit' call.
110 +# The default is to enable all implementations.
111 +#
112 +# PYTHON_COMPAT can be either a scalar or an array. If it's a scalar, the eclass
113 +# will implicitly convert it to an array.
114 +: ${PYTHON_COMPAT:=${_PYTHON_ALL_IMPLS[@]}}
115 +
116 +PYTHON_COMPAT=( ${PYTHON_COMPAT[@]} )
117 +
118 +_python_set_globals() {
119 + IUSE=${PYTHON_COMPAT[@]/#/python_targets_}
120 + REQUIRED_USE="|| ( ${IUSE} )"
121 +}
122 +_python_set_globals
123 --
124 1.7.12