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

Diff of /eclass/distutils.eclass

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

Revision 1.58 Revision 1.59
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.58 2009/08/05 18:34:56 arfrever Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/distutils.eclass,v 1.59 2009/08/12 02:24:34 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#
10# @BLURB: This eclass allows easier installation of distutils-based python modules 10# @BLURB: This eclass allows easier installation of distutils-based python modules
11# @DESCRIPTION: 11# @DESCRIPTION:
12# The distutils eclass is designed to allow easier installation of 12# The distutils eclass is designed to allow easier installation of
13# distutils-based python modules and their incorporation into 13# distutils-based python modules and their incorporation into
14# the Gentoo Linux system. 14# the Gentoo Linux system.
15#
16# It inherits python, multilib, and eutils
17 15
18inherit python multilib eutils 16inherit eutils multilib python
19 17
20case "${EAPI:-0}" in 18case "${EAPI:-0}" in
21 0|1) 19 0|1)
22 EXPORT_FUNCTIONS src_unpack src_compile src_install pkg_postinst pkg_postrm 20 EXPORT_FUNCTIONS src_unpack src_compile src_install pkg_postinst pkg_postrm
23 ;; 21 ;;
47 45
48# @FUNCTION: distutils_src_unpack 46# @FUNCTION: distutils_src_unpack
49# @DESCRIPTION: 47# @DESCRIPTION:
50# The distutils src_unpack function, this function is exported 48# The distutils src_unpack function, this function is exported
51distutils_src_unpack() { 49distutils_src_unpack() {
50 if [[ "${EBUILD_PHASE}" != "unpack" ]]; then
51 die "${FUNCNAME}() can be used only in src_unpack() phase"
52 fi
53
52 unpack ${A} 54 unpack ${A}
53 cd "${S}" 55 cd "${S}"
54 56
55 has "${EAPI:-0}" 0 1 && distutils_src_prepare 57 has "${EAPI:-0}" 0 1 && distutils_src_prepare
56} 58}
57 59
58# @FUNCTION: distutils_src_prepare 60# @FUNCTION: distutils_src_prepare
59# @DESCRIPTION: 61# @DESCRIPTION:
60# The distutils src_prepare function, this function is exported 62# The distutils src_prepare function, this function is exported
61distutils_src_prepare() { 63distutils_src_prepare() {
64 if ! has "${EAPI:-0}" 0 1 && [[ "${EBUILD_PHASE}" != "prepare" ]]; then
65 die "${FUNCNAME}() can be used only in src_prepare() phase"
66 fi
67
62 # remove ez_setup stuff to prevent packages 68 # remove ez_setup stuff to prevent packages
63 # from installing setuptools on their own 69 # from installing setuptools on their own
64 rm -rf ez_setup* 70 rm -rf ez_setup*
65 echo "def use_setuptools(*args, **kwargs): pass" > ez_setup.py 71 echo "def use_setuptools(*args, **kwargs): pass" > ez_setup.py
66} 72}
67 73
68# @FUNCTION: distutils_src_compile 74# @FUNCTION: distutils_src_compile
69# @DESCRIPTION: 75# @DESCRIPTION:
70# The distutils src_compile function, this function is exported 76# The distutils src_compile function, this function is exported
71distutils_src_compile() { 77distutils_src_compile() {
78 if [[ "${EBUILD_PHASE}" != "compile" ]]; then
79 die "${FUNCNAME}() can be used only in src_compile() phase"
80 fi
81
72 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then 82 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
73 build_modules() { 83 building() {
74 echo "$(PYTHON)" setup.py build -b "build-${PYTHON_ABI}" "$@" 84 echo "$(PYTHON)" setup.py build -b "build-${PYTHON_ABI}" "$@"
75 "$(PYTHON)" setup.py build -b "build-${PYTHON_ABI}" "$@" 85 "$(PYTHON)" setup.py build -b "build-${PYTHON_ABI}" "$@"
76 } 86 }
77 python_execute_function build_modules "$@" 87 python_execute_function building "$@"
78 else 88 else
89 echo ${python} setup.py build "$@"
79 ${python} setup.py build "$@" || die "compilation failed" 90 ${python} setup.py build "$@" || die "Building failed"
80 fi 91 fi
81} 92}
82 93
83# @FUNCTION: distutils_src_install 94# @FUNCTION: distutils_src_install
84# @DESCRIPTION: 95# @DESCRIPTION:
85# The distutils src_install function, this function is exported. 96# The distutils src_install function, this function is exported.
86# It also installs the "standard docs" (CHANGELOG, Change*, KNOWN_BUGS, MAINTAINERS, 97# It also installs the "standard docs" (CHANGELOG, Change*, KNOWN_BUGS, MAINTAINERS,
87# PKG-INFO, CONTRIBUTORS, TODO, NEWS, MANIFEST*, README*, and AUTHORS) 98# PKG-INFO, CONTRIBUTORS, TODO, NEWS, MANIFEST*, README*, and AUTHORS)
88distutils_src_install() { 99distutils_src_install() {
100 if [[ "${EBUILD_PHASE}" != "install" ]]; then
101 die "${FUNCNAME}() can be used only in src_install() phase"
102 fi
103
89 local pylibdir 104 local pylibdir
90 105
91 # Mark the package to be rebuilt after a python upgrade. 106 # Mark the package to be rebuilt after a python upgrade.
92 python_need_rebuild 107 python_need_rebuild
93 108
94 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then 109 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
95 install_modules() { 110 installation() {
96 # need this for python-2.5 + setuptools in cases where 111 # need this for python-2.5 + setuptools in cases where
97 # a package uses distutils but does not install anything 112 # a package uses distutils but does not install anything
98 # in site-packages. (eg. dev-java/java-config-2.x) 113 # in site-packages. (eg. dev-java/java-config-2.x)
99 # - liquidx (14/08/2006) 114 # - liquidx (14/08/2006)
100 pylibdir="$("$(PYTHON)" -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')" 115 pylibdir="$("$(PYTHON)" -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')"
101 [[ -n "${pylibdir}" ]] && dodir "${pylibdir}" 116 [[ -n "${pylibdir}" ]] && dodir "${pylibdir}"
102 117
103 echo "$(PYTHON)" setup.py build -b "build-${PYTHON_ABI}" install --root="${D}" --no-compile "$@" 118 echo "$(PYTHON)" setup.py build -b "build-${PYTHON_ABI}" install --root="${D}" --no-compile "$@"
104 "$(PYTHON)" setup.py build -b "build-${PYTHON_ABI}" install --root="${D}" --no-compile "$@" 119 "$(PYTHON)" setup.py build -b "build-${PYTHON_ABI}" install --root="${D}" --no-compile "$@"
105 } 120 }
106 python_execute_function install_modules "$@" 121 python_execute_function installation "$@"
107 else 122 else
108 # need this for python-2.5 + setuptools in cases where 123 # need this for python-2.5 + setuptools in cases where
109 # a package uses distutils but does not install anything 124 # a package uses distutils but does not install anything
110 # in site-packages. (eg. dev-java/java-config-2.x) 125 # in site-packages. (eg. dev-java/java-config-2.x)
111 # - liquidx (14/08/2006) 126 # - liquidx (14/08/2006)
112 pylibdir="$(${python} -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')" 127 pylibdir="$(${python} -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')"
113 [[ -n "${pylibdir}" ]] && dodir "${pylibdir}" 128 [[ -n "${pylibdir}" ]] && dodir "${pylibdir}"
114 129
130 echo ${python} setup.py install --root="${D}" --no-compile "$@"
115 ${python} setup.py install --root="${D}" --no-compile "$@" || die "python setup.py install failed" 131 ${python} setup.py install --root="${D}" --no-compile "$@" || die "Installation failed"
116 fi 132 fi
117 133
118 DDOCS="CHANGELOG KNOWN_BUGS MAINTAINERS PKG-INFO CONTRIBUTORS TODO NEWS" 134 DDOCS="CHANGELOG KNOWN_BUGS MAINTAINERS PKG-INFO CONTRIBUTORS TODO NEWS"
119 DDOCS="${DDOCS} Change* MANIFEST* README* AUTHORS" 135 DDOCS="${DDOCS} Change* MANIFEST* README* AUTHORS"
120 136
128 144
129# @FUNCTION: distutils_pkg_postrm 145# @FUNCTION: distutils_pkg_postrm
130# @DESCRIPTION: 146# @DESCRIPTION:
131# Generic pyc/pyo cleanup script. This function is exported. 147# Generic pyc/pyo cleanup script. This function is exported.
132distutils_pkg_postrm() { 148distutils_pkg_postrm() {
149 if [[ "${EBUILD_PHASE}" != "postrm" ]]; then
150 die "${FUNCNAME}() can be used only in pkg_postrm() phase"
151 fi
152
133 local pylibdir pymod 153 local pylibdir pymod
134 if [[ -z "${PYTHON_MODNAME}" ]]; then 154 if [[ -z "${PYTHON_MODNAME}" ]]; then
135 for pylibdir in "${ROOT}"/usr/$(get_libdir)/python*; do 155 for pylibdir in "${ROOT}"/usr/$(get_libdir)/python*; do
136 if [[ -d "${pylibdir}/site-packages/${PN}" ]]; then 156 if [[ -d "${pylibdir}/site-packages/${PN}" ]]; then
137 PYTHON_MODNAME="${PN}" 157 PYTHON_MODNAME="${PN}"
138 fi 158 fi
139 done 159 done
140 fi 160 fi
141 161
142 ebegin "Performing cleanup of Python modules..."
143 if [[ -n "${PYTHON_MODNAME}" ]]; then 162 if [[ -n "${PYTHON_MODNAME}" ]]; then
144 for pymod in ${PYTHON_MODNAME}; do 163 for pymod in ${PYTHON_MODNAME}; do
145 for pylibdir in "${ROOT}"/usr/$(get_libdir)/python*; do 164 for pylibdir in "${ROOT}"/usr/$(get_libdir)/python*; do
146 if [[ -d "${pylibdir}/site-packages/${pymod}" ]]; then 165 if [[ -d "${pylibdir}/site-packages/${pymod}" ]]; then
147 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then 166 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
153 done 172 done
154 done 173 done
155 else 174 else
156 python_mod_cleanup 175 python_mod_cleanup
157 fi 176 fi
158 eend 0
159} 177}
160 178
161# @FUNCTION: distutils_pkg_postinst 179# @FUNCTION: distutils_pkg_postinst
162# @DESCRIPTION: 180# @DESCRIPTION:
163# This is a generic optimization, you should override it if your package 181# This is a generic optimization, you should override it if your package
164# installs modules in another directory. This function is exported. 182# installs modules in another directory. This function is exported.
165distutils_pkg_postinst() { 183distutils_pkg_postinst() {
184 if [[ "${EBUILD_PHASE}" != "postinst" ]]; then
185 die "${FUNCNAME}() can be used only in pkg_postinst() phase"
186 fi
187
166 local pylibdir pymod 188 local pylibdir pymod
167 if [[ -z "${PYTHON_MODNAME}" ]]; then 189 if [[ -z "${PYTHON_MODNAME}" ]]; then
168 for pylibdir in "${ROOT}"/usr/$(get_libdir)/python*; do 190 for pylibdir in "${ROOT}"/usr/$(get_libdir)/python*; do
169 if [[ -d "${pylibdir}/site-packages/${PN}" ]]; then 191 if [[ -d "${pylibdir}/site-packages/${PN}" ]]; then
170 PYTHON_MODNAME="${PN}" 192 PYTHON_MODNAME="${PN}"

Legend:
Removed from v.1.58  
changed lines
  Added in v.1.59

  ViewVC Help
Powered by ViewVC 1.1.20