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

Diff of /eclass/distutils.eclass

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

Revision 1.64 Revision 1.67
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.64 2009/09/11 20:03:51 arfrever Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/distutils.eclass,v 1.67 2009/11/28 18:39:27 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#
40 40
41# @ECLASS-VARIABLE: DOCS 41# @ECLASS-VARIABLE: DOCS
42# @DESCRIPTION: 42# @DESCRIPTION:
43# Additional DOCS 43# Additional DOCS
44 44
45_distutils_hook() {
46 if [[ "$#" -ne 1 ]]; then
47 die "${FUNCNAME}() requires 1 argument"
48 fi
49 if [[ "$(type -t "distutils_src_${EBUILD_PHASE}_$1_hook")" == "function" ]]; then
50 "distutils_src_${EBUILD_PHASE}_$1_hook"
51 fi
52}
53
45# @FUNCTION: distutils_src_unpack 54# @FUNCTION: distutils_src_unpack
46# @DESCRIPTION: 55# @DESCRIPTION:
47# The distutils src_unpack function, this function is exported 56# The distutils src_unpack function, this function is exported.
48distutils_src_unpack() { 57distutils_src_unpack() {
49 if [[ "${EBUILD_PHASE}" != "unpack" ]]; then 58 if [[ "${EBUILD_PHASE}" != "unpack" ]]; then
50 die "${FUNCNAME}() can be used only in src_unpack() phase" 59 die "${FUNCNAME}() can be used only in src_unpack() phase"
51 fi 60 fi
52 61
56 has "${EAPI:-0}" 0 1 && distutils_src_prepare 65 has "${EAPI:-0}" 0 1 && distutils_src_prepare
57} 66}
58 67
59# @FUNCTION: distutils_src_prepare 68# @FUNCTION: distutils_src_prepare
60# @DESCRIPTION: 69# @DESCRIPTION:
61# The distutils src_prepare function, this function is exported 70# The distutils src_prepare function, this function is exported.
62distutils_src_prepare() { 71distutils_src_prepare() {
63 if ! has "${EAPI:-0}" 0 1 && [[ "${EBUILD_PHASE}" != "prepare" ]]; then 72 if ! has "${EAPI:-0}" 0 1 && [[ "${EBUILD_PHASE}" != "prepare" ]]; then
64 die "${FUNCNAME}() can be used only in src_prepare() phase" 73 die "${FUNCNAME}() can be used only in src_prepare() phase"
65 fi 74 fi
66 75
67 # Delete ez_setup files to prevent packages from installing 76 # Delete ez_setup files to prevent packages from installing
68 # setuptools on their own. 77 # Setuptools on their own.
69 local ez_setup_existence 78 local ez_setup_existence="0"
70 [[ -d ez_setup || -f ez_setup.py ]] && ez_setup_existence="1" 79 [[ -d ez_setup || -f ez_setup.py ]] && ez_setup_existence="1"
71 rm -fr ez_setup* 80 rm -fr ez_setup*
72 if [[ "${ez_setup_existence}" == "1" ]]; then 81 if [[ "${ez_setup_existence}" == "1" ]]; then
73 echo "def use_setuptools(*args, **kwargs): pass" > ez_setup.py 82 echo "def use_setuptools(*args, **kwargs): pass" > ez_setup.py
74 fi 83 fi
75 84
85 # Delete distribute_setup files to prevent packages from installing
86 # Distribute on their own.
87 local distribute_setup_existence="0"
88 [[ -d distribute_setup || -f distribute_setup.py ]] && distribute_setup_existence="1"
89 rm -fr distribute_setup*
90 if [[ "${distribute_setup_existence}" == "1" ]]; then
91 echo "def use_setuptools(*args, **kwargs): pass" > distribute_setup.py
92 fi
93
76 if [[ -n "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]]; then 94 if [[ -n "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]]; then
77 python_copy_sources 95 python_copy_sources
78 fi 96 fi
79} 97}
80 98
81# @FUNCTION: distutils_src_compile 99# @FUNCTION: distutils_src_compile
82# @DESCRIPTION: 100# @DESCRIPTION:
83# The distutils src_compile function, this function is exported 101# The distutils src_compile function, this function is exported.
102# In newer EAPIs this function calls distutils_src_compile_pre_hook() and
103# distutils_src_compile_post_hook(), if they are defined.
84distutils_src_compile() { 104distutils_src_compile() {
85 if [[ "${EBUILD_PHASE}" != "compile" ]]; then 105 if [[ "${EBUILD_PHASE}" != "compile" ]]; then
86 die "${FUNCNAME}() can be used only in src_compile() phase" 106 die "${FUNCNAME}() can be used only in src_compile() phase"
87 fi 107 fi
88 108
89 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
90 if [[ -n "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]]; then 110 if [[ -n "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]]; then
91 building() { 111 building() {
112 _distutils_hook pre
113
92 echo "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build "$@" 114 echo "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build "$@"
93 "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build "$@" 115 "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build "$@" || return "$?"
116
117 _distutils_hook post
94 } 118 }
95 python_execute_function -s building "$@" 119 python_execute_function -s building "$@"
96 else 120 else
97 building() { 121 building() {
122 _distutils_hook pre
123
98 echo "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build -b "build-${PYTHON_ABI}" "$@" 124 echo "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build -b "build-${PYTHON_ABI}" "$@"
99 "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build -b "build-${PYTHON_ABI}" "$@" 125 "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build -b "build-${PYTHON_ABI}" "$@" || return "$?"
126
127 _distutils_hook post
100 } 128 }
101 python_execute_function building "$@" 129 python_execute_function building "$@"
102 fi 130 fi
103 else 131 else
132 python_version
104 echo ${python} setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build "$@" 133 echo "$(PYTHON "${PYVER}")" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build "$@"
105 ${python} setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build "$@" || die "Building failed" 134 "$(PYTHON "${PYVER}")" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build "$@" || die "Building failed"
106 fi 135 fi
107} 136}
108 137
109# @FUNCTION: distutils_src_install 138# @FUNCTION: distutils_src_install
110# @DESCRIPTION: 139# @DESCRIPTION:
111# The distutils src_install function, this function is exported. 140# The distutils src_install function, this function is exported.
141# In newer EAPIs this function calls distutils_src_install_pre_hook() and
142# distutils_src_install_post_hook(), if they are defined.
112# It also installs the "standard docs" (CHANGELOG, Change*, KNOWN_BUGS, MAINTAINERS, 143# It also installs the "standard docs" (CHANGELOG, Change*, KNOWN_BUGS, MAINTAINERS,
113# PKG-INFO, CONTRIBUTORS, TODO, NEWS, MANIFEST*, README*, and AUTHORS) 144# PKG-INFO, CONTRIBUTORS, TODO, NEWS, MANIFEST*, README*, and AUTHORS)
114distutils_src_install() { 145distutils_src_install() {
115 if [[ "${EBUILD_PHASE}" != "install" ]]; then 146 if [[ "${EBUILD_PHASE}" != "install" ]]; then
116 die "${FUNCNAME}() can be used only in src_install() phase" 147 die "${FUNCNAME}() can be used only in src_install() phase"
122 python_need_rebuild 153 python_need_rebuild
123 154
124 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then 155 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
125 if [[ -n "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]]; then 156 if [[ -n "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]]; then
126 installation() { 157 installation() {
158 _distutils_hook pre
159
127 # need this for python-2.5 + setuptools in cases where 160 # need this for python-2.5 + setuptools in cases where
128 # a package uses distutils but does not install anything 161 # a package uses distutils but does not install anything
129 # in site-packages. (eg. dev-java/java-config-2.x) 162 # in site-packages. (eg. dev-java/java-config-2.x)
130 # - liquidx (14/08/2006) 163 # - liquidx (14/08/2006)
131 pylibdir="$("$(PYTHON)" -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')" 164 pylibdir="$("$(PYTHON)" -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')"
132 [[ -n "${pylibdir}" ]] && dodir "${pylibdir}" 165 [[ -n "${pylibdir}" ]] && dodir "${pylibdir}"
133 166
134 echo "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@" 167 echo "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@"
135 "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@" 168 "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@" || return "$?"
169
170 _distutils_hook post
136 } 171 }
137 python_execute_function -s installation "$@" 172 python_execute_function -s installation "$@"
138 else 173 else
139 installation() { 174 installation() {
175 _distutils_hook pre
176
140 # need this for python-2.5 + setuptools in cases where 177 # need this for python-2.5 + setuptools in cases where
141 # a package uses distutils but does not install anything 178 # a package uses distutils but does not install anything
142 # in site-packages. (eg. dev-java/java-config-2.x) 179 # in site-packages. (eg. dev-java/java-config-2.x)
143 # - liquidx (14/08/2006) 180 # - liquidx (14/08/2006)
144 pylibdir="$("$(PYTHON)" -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')" 181 pylibdir="$("$(PYTHON)" -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')"
145 [[ -n "${pylibdir}" ]] && dodir "${pylibdir}" 182 [[ -n "${pylibdir}" ]] && dodir "${pylibdir}"
146 183
147 echo "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build -b "build-${PYTHON_ABI}" install --root="${D}" --no-compile "$@" 184 echo "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build -b "build-${PYTHON_ABI}" install --root="${D}" --no-compile "$@"
148 "$(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 "$?"
186
187 _distutils_hook post
149 } 188 }
150 python_execute_function installation "$@" 189 python_execute_function installation "$@"
151 fi 190 fi
152 else 191 else
153 # need this for python-2.5 + setuptools in cases where 192 # need this for python-2.5 + setuptools in cases where
154 # a package uses distutils but does not install anything 193 # a package uses distutils but does not install anything
155 # in site-packages. (eg. dev-java/java-config-2.x) 194 # in site-packages. (eg. dev-java/java-config-2.x)
156 # - liquidx (14/08/2006) 195 # - liquidx (14/08/2006)
157 pylibdir="$(${python} -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')" 196 pylibdir="$("$(PYTHON "${PYVER}")" -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')"
158 [[ -n "${pylibdir}" ]] && dodir "${pylibdir}" 197 [[ -n "${pylibdir}" ]] && dodir "${pylibdir}"
159 198
160 echo ${python} setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@" 199 echo "$(PYTHON "${PYVER}")" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@"
161 ${python} setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@" || die "Installation failed" 200 "$(PYTHON "${PYVER}")" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@" || die "Installation failed"
162 fi 201 fi
163 202
164 if [[ -e "${D}usr/local" ]]; then 203 if [[ -e "${D}usr/local" ]]; then
165 die "Illegal installation into /usr/local" 204 die "Illegal installation into /usr/local"
166 fi 205 fi
195 fi 234 fi
196 done 235 done
197 fi 236 fi
198 237
199 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then 238 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
200 for pymod in ${PYTHON_MODNAME}; do 239 python_mod_optimize ${PYTHON_MODNAME}
201 python_mod_optimize "${pymod}"
202 done
203 else 240 else
204 for pymod in ${PYTHON_MODNAME}; do 241 for pymod in ${PYTHON_MODNAME}; do
205 python_mod_optimize "$(python_get_sitedir)/${pymod}" 242 python_mod_optimize "$(python_get_sitedir)/${pymod}"
206 done 243 done
207 fi 244 fi
223 fi 260 fi
224 done 261 done
225 fi 262 fi
226 263
227 if [[ -n "${PYTHON_MODNAME}" ]]; then 264 if [[ -n "${PYTHON_MODNAME}" ]]; then
228 for pymod in ${PYTHON_MODNAME}; do
229 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then 265 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
230 python_mod_cleanup "${pymod}" 266 python_mod_cleanup ${PYTHON_MODNAME}
231 else 267 else
268 for pymod in ${PYTHON_MODNAME}; do
232 for pylibdir in "${ROOT}"/usr/$(get_libdir)/python*; do 269 for pylibdir in "${ROOT}"/usr/$(get_libdir)/python*; do
233 if [[ -d "${pylibdir}/site-packages/${pymod}" ]]; then 270 if [[ -d "${pylibdir}/site-packages/${pymod}" ]]; then
234 python_mod_cleanup "${pylibdir#${ROOT}}/site-packages/${pymod}" 271 python_mod_cleanup "${pylibdir#${ROOT}}/site-packages/${pymod}"
235 fi 272 fi
236 done 273 done
237 fi
238 done 274 done
275 fi
239 else 276 else
240 python_mod_cleanup 277 python_mod_cleanup
241 fi 278 fi
242} 279}
243 280
244# @FUNCTION: distutils_python_version 281# @FUNCTION: distutils_python_version
245# @DESCRIPTION: 282# @DESCRIPTION:
246# Calls python_version, so that you can use something like 283# Calls python_version, so that you can use something like
247# e.g. insinto ${ROOT}/usr/include/python${PYVER} 284# e.g. insinto ${ROOT}/usr/include/python${PYVER}
248distutils_python_version() { 285distutils_python_version() {
249 python_version 286 python_version
250} 287}
251 288
252# @FUNCTION: distutils_python_tkinter 289# @FUNCTION: distutils_python_tkinter

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

  ViewVC Help
Powered by ViewVC 1.1.20