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

Diff of /eclass/python.eclass

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

Revision 1.54 Revision 1.55
1# Copyright 1999-2008 Gentoo Foundation 1# Copyright 1999-2008 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.54 2008/10/30 05:21:46 zmedico Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.55 2009/05/27 22:49:32 betelgeuse Exp $
4 4
5# @ECLASS: python.eclass 5# @ECLASS: python.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# python@gentoo.org 7# python@gentoo.org
8# 8#
12# Some useful functions for dealing with python. 12# Some useful functions for dealing with python.
13inherit alternatives multilib 13inherit alternatives multilib
14 14
15 15
16if [[ -n "${NEED_PYTHON}" ]] ; then 16if [[ -n "${NEED_PYTHON}" ]] ; then
17 DEPEND=">=dev-lang/python-${NEED_PYTHON}" 17 PYTHON_ATOM=">=dev-lang/python-${NEED_PYTHON}"
18 DEPEND="${PYTHON_ATOM}"
18 RDEPEND="${DEPEND}" 19 RDEPEND="${DEPEND}"
20else
21 PYTHON_ATOM="dev-lang/python"
19fi 22fi
20 23
21__python_eclass_test() { 24__python_eclass_test() {
22 __python_version_extract 2.3 25 __python_version_extract 2.3
23 echo -n "2.3 -> PYVER: $PYVER PYVER_MAJOR: $PYVER_MAJOR" 26 echo -n "2.3 -> PYVER: $PYVER PYVER_MAJOR: $PYVER_MAJOR"
56 python=${python:-/usr/bin/python} 59 python=${python:-/usr/bin/python}
57 tmpstr="$(${python} -V 2>&1 )" 60 tmpstr="$(${python} -V 2>&1 )"
58 export PYVER_ALL="${tmpstr#Python }" 61 export PYVER_ALL="${tmpstr#Python }"
59 __python_version_extract $PYVER_ALL 62 __python_version_extract $PYVER_ALL
60} 63}
64
65# @ECLASS-VARIABLE: PYTHON_USE_WITH
66# @DESCRIPTION:
67# Set this to a space separated list of use flags
68# the python slot in use must be built with.
69
70# @ECLASS-VARIABLE: PYTHON_USE_WITH_OR
71# @DESCRIPTION:
72# Set this to a space separated list of use flags
73# of which one must be turned on for the slot of
74# in use.
75
76# @ECLASS-VARIABLE: PYTHON_USE_WITH_OPT
77# @DESCRIPTION:
78# Set this if you need to make either PYTHON_USE_WITH or
79# PYTHON_USE_WITH_OR atoms conditional under a use flag.
80
81# @FUNCTION: python_pkg_setup
82# @DESCRIPTION:
83# Makes sure PYTHON_USE_WITH or PYTHON_USE_WITH_OR listed use flags
84# are respected. Only exported if one of those variables is set.
85if ! has ${EAPI} 0 1 && [[ -n ${PYTHON_USE_WITH} || -n ${PYTHON_USE_WITH_OR} ]]; then
86 python_pkg_setup_fail() {
87 eerror "${1}"
88 die "${1}"
89 }
90
91 python_pkg_setup() {
92 [[ ${PYTHON_USE_WITH_OPT} ]] && use !${PYTHON_USE_WITH_OPT} && return
93
94 python_version
95 local failed
96 local pyatom="dev-lang/python:${PYVER}"
97
98 for use in ${PYTHON_USE_WITH}; do
99 if ! has_version "${pyatom}[${use}]"; then
100 python_pkg_setup_fail \
101 "Please rebuild ${pyatom} with use flags: ${PYTHON_USE_WITH}"
102 fi
103 done
104
105 for use in ${PYTHON_USE_WITH_OR}; do
106 if has_version "${pyatom}[${use}]"; then
107 return
108 fi
109 done
110
111 if [[ ${PYTHON_USE_WITH_OR} ]]; then
112 python_pkg_setup_fail \
113 "Please rebuild ${pyatom} with one of: ${PYTHON_USE_WITH_OR}"
114 fi
115 }
116
117 EXPORT_FUNCTIONS pkg_setup
118
119 if [[ ${PYTHON_USE_WITH} ]]; then
120 PYTHON_USE_WITH_ATOM="${PYTHON_ATOM}[${PYTHON_USE_WITH/ /,}]"
121 elif [[ ${PYTHON_USE_WITH_OR} ]]; then
122 PYTHON_USE_WITH_ATOM="|| ( "
123 for use in ${PYTHON_USE_WITH_OR}; do
124 PYTHON_USE_WITH_ATOM="
125 ${PYTHON_USE_WITH_ATOM}
126 ${PYTHON_ATOM}[${use}]"
127 done
128 PYTHON_USE_WITH_ATOM="${PYTHON_USE_WITH_ATOM} )"
129 fi
130 if [[ ${PYTHON_USE_WITH_OPT} ]]; then
131 PYTHON_USE_WITH_ATOM="${PYTHON_USE_WITH_OPT}? ( ${PYTHON_USE_WITH_ATOM} )"
132 fi
133 DEPEND="${PYTHON_USE_WITH_ATOM}"
134 RDEPEND="${PYTHON_USE_WITH_ATOM}"
135fi
61 136
62# @FUNCTION: python_disable_pyc 137# @FUNCTION: python_disable_pyc
63# @DESCRIPTION: 138# @DESCRIPTION:
64# Tells python not to automatically recompile modules to .pyc/.pyo 139# Tells python not to automatically recompile modules to .pyc/.pyo
65# even if the timestamps/version stamps don't match. This is done 140# even if the timestamps/version stamps don't match. This is done

Legend:
Removed from v.1.54  
changed lines
  Added in v.1.55

  ViewVC Help
Powered by ViewVC 1.1.20