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