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

Diff of /eclass/distutils.eclass

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

Revision 1.67 Revision 1.69
1# Copyright 1999-2009 Gentoo Foundation 1# Copyright 1999-2009 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/distutils.eclass,v 1.67 2009/11/28 18:39:27 arfrever Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/distutils.eclass,v 1.69 2010/01/10 17:24:32 arfrever Exp $
4 4
5# @ECLASS: distutils.eclass 5# @ECLASS: distutils.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# <python@gentoo.org> 7# <python@gentoo.org>
8# 8#
26 26
27if [[ -z "${DISTUTILS_DISABLE_PYTHON_DEPENDENCY}" ]]; then 27if [[ -z "${DISTUTILS_DISABLE_PYTHON_DEPENDENCY}" ]]; then
28 DEPEND="virtual/python" 28 DEPEND="virtual/python"
29 RDEPEND="${DEPEND}" 29 RDEPEND="${DEPEND}"
30fi 30fi
31
32if has "${EAPI:-0}" 0 1 2; then
31python="python" 33 python="python"
34else
35 python="die"
36fi
32 37
33# @ECLASS-VARIABLE: DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES 38# @ECLASS-VARIABLE: DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES
34# @DESCRIPTION: 39# @DESCRIPTION:
35# Set this to use separate source directories for each enabled version of Python. 40# Set this to use separate source directories for each enabled version of Python.
36 41
37# @ECLASS-VARIABLE: DISTUTILS_GLOBAL_OPTIONS 42# @ECLASS-VARIABLE: DISTUTILS_GLOBAL_OPTIONS
38# @DESCRIPTION: 43# @DESCRIPTION:
39# Global options passed to setup.py. 44# Global options passed to setup.py.
45
46# @ECLASS-VARIABLE: DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS
47# @DESCRIPTION:
48# Set this to disable renaming of Python scripts containing versioned shebangs
49# and generation of wrapper scripts.
40 50
41# @ECLASS-VARIABLE: DOCS 51# @ECLASS-VARIABLE: DOCS
42# @DESCRIPTION: 52# @DESCRIPTION:
43# Additional DOCS 53# Additional DOCS
44 54
127 _distutils_hook post 137 _distutils_hook post
128 } 138 }
129 python_execute_function building "$@" 139 python_execute_function building "$@"
130 fi 140 fi
131 else 141 else
132 python_version
133 echo "$(PYTHON "${PYVER}")" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build "$@" 142 echo "$(PYTHON -A)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build "$@"
134 "$(PYTHON "${PYVER}")" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build "$@" || die "Building failed" 143 "$(PYTHON -A)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build "$@" || die "Building failed"
135 fi 144 fi
136} 145}
137 146
138# @FUNCTION: distutils_src_install 147# @FUNCTION: distutils_src_install
139# @DESCRIPTION: 148# @DESCRIPTION:
147 die "${FUNCNAME}() can be used only in src_install() phase" 156 die "${FUNCNAME}() can be used only in src_install() phase"
148 fi 157 fi
149 158
150 local pylibdir 159 local pylibdir
151 160
152 # Mark the package to be rebuilt after a python upgrade.
153 python_need_rebuild
154
155 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then 161 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
162 if [[ -z "${DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS}" && "${BASH_VERSINFO[0]}" -ge "4" ]]; then
163 declare -A wrapper_scripts=()
164
165 rename_scripts_with_versioned_shebangs() {
166 if [[ -d "${D}usr/bin" ]]; then
167 cd "${D}usr/bin"
168
169 local file
170 for file in *; do
171 if [[ -f "${file}" && ! "${file}" =~ [[:digit:]]+\.[[:digit:]]+$ && "$(head -n1 "${file}")" =~ ^'#!'.*python[[:digit:]]+\.[[:digit:]]+ ]]; then
172 mv "${file}" "${file}-${PYTHON_ABI}" || die "Renaming of '${file}' failed"
173 wrapper_scripts+=(["${D}usr/bin/${file}"]=)
174 fi
175 done
176 fi
177 }
178 fi
179
156 if [[ -n "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]]; then 180 if [[ -n "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]]; then
157 installation() { 181 installation() {
158 _distutils_hook pre 182 _distutils_hook pre
159 183
160 # need this for python-2.5 + setuptools in cases where 184 # need this for python-2.5 + setuptools in cases where
165 [[ -n "${pylibdir}" ]] && dodir "${pylibdir}" 189 [[ -n "${pylibdir}" ]] && dodir "${pylibdir}"
166 190
167 echo "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@" 191 echo "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@"
168 "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@" || return "$?" 192 "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@" || return "$?"
169 193
194 if [[ -z "${DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS}" && "${BASH_VERSINFO[0]}" -ge "4" ]]; then
195 rename_scripts_with_versioned_shebangs
196 fi
197
170 _distutils_hook post 198 _distutils_hook post
171 } 199 }
172 python_execute_function -s installation "$@" 200 python_execute_function -s installation "$@"
173 else 201 else
174 installation() { 202 installation() {
182 [[ -n "${pylibdir}" ]] && dodir "${pylibdir}" 210 [[ -n "${pylibdir}" ]] && dodir "${pylibdir}"
183 211
184 echo "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build -b "build-${PYTHON_ABI}" install --root="${D}" --no-compile "$@" 212 echo "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build -b "build-${PYTHON_ABI}" install --root="${D}" --no-compile "$@"
185 "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build -b "build-${PYTHON_ABI}" install --root="${D}" --no-compile "$@" || return "$?" 213 "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build -b "build-${PYTHON_ABI}" install --root="${D}" --no-compile "$@" || return "$?"
186 214
215 if [[ -z "${DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS}" && "${BASH_VERSINFO[0]}" -ge "4" ]]; then
216 rename_scripts_with_versioned_shebangs
217 fi
218
187 _distutils_hook post 219 _distutils_hook post
188 } 220 }
189 python_execute_function installation "$@" 221 python_execute_function installation "$@"
190 fi 222 fi
223
224 if [[ -z "${DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS}" && "${#wrapper_scripts[@]}" -ne "0" && "${BASH_VERSINFO[0]}" -ge "4" ]]; then
225 python_generate_wrapper_scripts "${!wrapper_scripts[@]}"
226 fi
227 unset wrapper_scripts
191 else 228 else
229 # Mark the package to be rebuilt after a Python upgrade.
230 python_need_rebuild
231
192 # need this for python-2.5 + setuptools in cases where 232 # need this for python-2.5 + setuptools in cases where
193 # a package uses distutils but does not install anything 233 # a package uses distutils but does not install anything
194 # in site-packages. (eg. dev-java/java-config-2.x) 234 # in site-packages. (eg. dev-java/java-config-2.x)
195 # - liquidx (14/08/2006) 235 # - liquidx (14/08/2006)
196 pylibdir="$("$(PYTHON "${PYVER}")" -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')" 236 pylibdir="$("$(PYTHON -A)" -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')"
197 [[ -n "${pylibdir}" ]] && dodir "${pylibdir}" 237 [[ -n "${pylibdir}" ]] && dodir "${pylibdir}"
198 238
199 echo "$(PYTHON "${PYVER}")" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@" 239 echo "$(PYTHON -A)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@"
200 "$(PYTHON "${PYVER}")" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@" || die "Installation failed" 240 "$(PYTHON -A)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@" || die "Installation failed"
201 fi 241 fi
202 242
203 if [[ -e "${D}usr/local" ]]; then 243 if [[ -e "${D}usr/local" ]]; then
204 die "Illegal installation into /usr/local" 244 die "Illegal installation into /usr/local"
205 fi 245 fi
279} 319}
280 320
281# @FUNCTION: distutils_python_version 321# @FUNCTION: distutils_python_version
282# @DESCRIPTION: 322# @DESCRIPTION:
283# Calls python_version, so that you can use something like 323# Calls python_version, so that you can use something like
284# e.g. insinto ${ROOT}/usr/include/python${PYVER} 324# e.g. insinto $(python_get_includedir)
285distutils_python_version() { 325distutils_python_version() {
326 if ! has "${EAPI:-0}" 0 1 2; then
327 die "${FUNCNAME}() cannot be used in this EAPI"
328 fi
329
286 python_version 330 python_version
287} 331}
288 332
289# @FUNCTION: distutils_python_tkinter 333# @FUNCTION: distutils_python_tkinter
290# @DESCRIPTION: 334# @DESCRIPTION:
291# Checks for if tkinter support is compiled into python 335# Checks for if tkinter support is compiled into python
292distutils_python_tkinter() { 336distutils_python_tkinter() {
337 if ! has "${EAPI:-0}" 0 1 2; then
338 die "${FUNCNAME}() cannot be used in this EAPI"
339 fi
340
293 python_tkinter_exists 341 python_tkinter_exists
294} 342}

Legend:
Removed from v.1.67  
changed lines
  Added in v.1.69

  ViewVC Help
Powered by ViewVC 1.1.20