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

Diff of /eclass/distutils.eclass

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

Revision 1.59 Revision 1.64
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.59 2009/08/12 02:24:34 arfrever Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/distutils.eclass,v 1.64 2009/09/11 20:03:51 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#
22 *) 22 *)
23 EXPORT_FUNCTIONS src_unpack src_prepare src_compile src_install pkg_postinst pkg_postrm 23 EXPORT_FUNCTIONS src_unpack src_prepare src_compile src_install pkg_postinst pkg_postrm
24 ;; 24 ;;
25esac 25esac
26 26
27# @ECLASS-VARIABLE: PYTHON_SLOT_VERSION 27if [[ -z "${DISTUTILS_DISABLE_PYTHON_DEPENDENCY}" ]]; then
28# @DESCRIPTION:
29# This helps make it possible to add extensions to python slots.
30# Normally only a -py21- ebuild would set PYTHON_SLOT_VERSION.
31if [ "${PYTHON_SLOT_VERSION}" = "2.1" ] ; then
32 DEPEND="=dev-lang/python-2.1*"
33 python="python2.1"
34elif [ "${PYTHON_SLOT_VERSION}" = "2.3" ] ; then
35 DEPEND="=dev-lang/python-2.3*"
36 python="python2.3"
37else
38 DEPEND="virtual/python" 28 DEPEND="virtual/python"
39 python="python" 29 RDEPEND="${DEPEND}"
40fi 30fi
31python="python"
32
33# @ECLASS-VARIABLE: DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES
34# @DESCRIPTION:
35# Set this to use separate source directories for each enabled version of Python.
36
37# @ECLASS-VARIABLE: DISTUTILS_GLOBAL_OPTIONS
38# @DESCRIPTION:
39# Global options passed to setup.py.
41 40
42# @ECLASS-VARIABLE: DOCS 41# @ECLASS-VARIABLE: DOCS
43# @DESCRIPTION: 42# @DESCRIPTION:
44# Additional DOCS 43# Additional DOCS
45 44
63distutils_src_prepare() { 62distutils_src_prepare() {
64 if ! has "${EAPI:-0}" 0 1 && [[ "${EBUILD_PHASE}" != "prepare" ]]; then 63 if ! has "${EAPI:-0}" 0 1 && [[ "${EBUILD_PHASE}" != "prepare" ]]; then
65 die "${FUNCNAME}() can be used only in src_prepare() phase" 64 die "${FUNCNAME}() can be used only in src_prepare() phase"
66 fi 65 fi
67 66
68 # remove ez_setup stuff to prevent packages 67 # Delete ez_setup files to prevent packages from installing
69 # from installing setuptools on their own 68 # setuptools on their own.
69 local ez_setup_existence
70 [[ -d ez_setup || -f ez_setup.py ]] && ez_setup_existence="1"
70 rm -rf ez_setup* 71 rm -fr ez_setup*
72 if [[ "${ez_setup_existence}" == "1" ]]; then
71 echo "def use_setuptools(*args, **kwargs): pass" > ez_setup.py 73 echo "def use_setuptools(*args, **kwargs): pass" > ez_setup.py
74 fi
75
76 if [[ -n "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]]; then
77 python_copy_sources
78 fi
72} 79}
73 80
74# @FUNCTION: distutils_src_compile 81# @FUNCTION: distutils_src_compile
75# @DESCRIPTION: 82# @DESCRIPTION:
76# The distutils src_compile function, this function is exported 83# The distutils src_compile function, this function is exported
78 if [[ "${EBUILD_PHASE}" != "compile" ]]; then 85 if [[ "${EBUILD_PHASE}" != "compile" ]]; then
79 die "${FUNCNAME}() can be used only in src_compile() phase" 86 die "${FUNCNAME}() can be used only in src_compile() phase"
80 fi 87 fi
81 88
82 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then 89 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
90 if [[ -n "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]]; then
83 building() { 91 building() {
84 echo "$(PYTHON)" setup.py build -b "build-${PYTHON_ABI}" "$@" 92 echo "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build "$@"
85 "$(PYTHON)" setup.py build -b "build-${PYTHON_ABI}" "$@" 93 "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build "$@"
86 } 94 }
95 python_execute_function -s building "$@"
96 else
97 building() {
98 echo "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build -b "build-${PYTHON_ABI}" "$@"
99 "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build -b "build-${PYTHON_ABI}" "$@"
100 }
87 python_execute_function building "$@" 101 python_execute_function building "$@"
102 fi
88 else 103 else
89 echo ${python} setup.py build "$@" 104 echo ${python} setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build "$@"
90 ${python} setup.py build "$@" || die "Building failed" 105 ${python} setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build "$@" || die "Building failed"
91 fi 106 fi
92} 107}
93 108
94# @FUNCTION: distutils_src_install 109# @FUNCTION: distutils_src_install
95# @DESCRIPTION: 110# @DESCRIPTION:
105 120
106 # Mark the package to be rebuilt after a python upgrade. 121 # Mark the package to be rebuilt after a python upgrade.
107 python_need_rebuild 122 python_need_rebuild
108 123
109 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then 124 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
125 if [[ -n "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]]; then
110 installation() { 126 installation() {
111 # need this for python-2.5 + setuptools in cases where 127 # need this for python-2.5 + setuptools in cases where
112 # a package uses distutils but does not install anything 128 # a package uses distutils but does not install anything
113 # in site-packages. (eg. dev-java/java-config-2.x) 129 # in site-packages. (eg. dev-java/java-config-2.x)
114 # - liquidx (14/08/2006) 130 # - liquidx (14/08/2006)
115 pylibdir="$("$(PYTHON)" -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')" 131 pylibdir="$("$(PYTHON)" -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')"
116 [[ -n "${pylibdir}" ]] && dodir "${pylibdir}" 132 [[ -n "${pylibdir}" ]] && dodir "${pylibdir}"
117 133
118 echo "$(PYTHON)" setup.py build -b "build-${PYTHON_ABI}" install --root="${D}" --no-compile "$@" 134 echo "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@"
119 "$(PYTHON)" setup.py build -b "build-${PYTHON_ABI}" install --root="${D}" --no-compile "$@" 135 "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@"
120 } 136 }
137 python_execute_function -s installation "$@"
138 else
139 installation() {
140 # need this for python-2.5 + setuptools in cases where
141 # a package uses distutils but does not install anything
142 # in site-packages. (eg. dev-java/java-config-2.x)
143 # - liquidx (14/08/2006)
144 pylibdir="$("$(PYTHON)" -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')"
145 [[ -n "${pylibdir}" ]] && dodir "${pylibdir}"
146
147 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 "$@"
149 }
121 python_execute_function installation "$@" 150 python_execute_function installation "$@"
151 fi
122 else 152 else
123 # need this for python-2.5 + setuptools in cases where 153 # need this for python-2.5 + setuptools in cases where
124 # a package uses distutils but does not install anything 154 # a package uses distutils but does not install anything
125 # in site-packages. (eg. dev-java/java-config-2.x) 155 # in site-packages. (eg. dev-java/java-config-2.x)
126 # - liquidx (14/08/2006) 156 # - liquidx (14/08/2006)
127 pylibdir="$(${python} -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')" 157 pylibdir="$(${python} -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')"
128 [[ -n "${pylibdir}" ]] && dodir "${pylibdir}" 158 [[ -n "${pylibdir}" ]] && dodir "${pylibdir}"
129 159
130 echo ${python} setup.py install --root="${D}" --no-compile "$@" 160 echo ${python} setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@"
131 ${python} setup.py install --root="${D}" --no-compile "$@" || die "Installation failed" 161 ${python} setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@" || die "Installation failed"
132 fi 162 fi
133 163
134 DDOCS="CHANGELOG KNOWN_BUGS MAINTAINERS PKG-INFO CONTRIBUTORS TODO NEWS" 164 if [[ -e "${D}usr/local" ]]; then
135 DDOCS="${DDOCS} Change* MANIFEST* README* AUTHORS" 165 die "Illegal installation into /usr/local"
166 fi
167
168 local default_docs
169 default_docs="AUTHORS Change* CHANGELOG CONTRIBUTORS KNOWN_BUGS MAINTAINERS MANIFEST* NEWS PKG-INFO README* TODO"
136 170
137 local doc 171 local doc
138 for doc in ${DDOCS}; do 172 for doc in ${default_docs}; do
139 [[ -s "$doc" ]] && dodoc $doc 173 [[ -s "${doc}" ]] && dodoc "${doc}"
140 done 174 done
141 175
142 [[ -n "${DOCS}" ]] && dodoc ${DOCS} 176 if [[ -n "${DOCS}" ]]; then
177 dodoc ${DOCS} || die "dodoc failed"
178 fi
143} 179}
144 180
145# @FUNCTION: distutils_pkg_postrm 181# @FUNCTION: distutils_pkg_postinst
146# @DESCRIPTION: 182# @DESCRIPTION:
147# Generic pyc/pyo cleanup script. This function is exported. 183# This is a generic optimization, you should override it if your package
184# installs modules in another directory. This function is exported.
148distutils_pkg_postrm() { 185distutils_pkg_postinst() {
149 if [[ "${EBUILD_PHASE}" != "postrm" ]]; then 186 if [[ "${EBUILD_PHASE}" != "postinst" ]]; then
150 die "${FUNCNAME}() can be used only in pkg_postrm() phase" 187 die "${FUNCNAME}() can be used only in pkg_postinst() phase"
151 fi 188 fi
152 189
153 local pylibdir pymod 190 local pylibdir pymod
154 if [[ -z "${PYTHON_MODNAME}" ]]; then 191 if [[ -z "${PYTHON_MODNAME}" ]]; then
155 for pylibdir in "${ROOT}"/usr/$(get_libdir)/python*; do 192 for pylibdir in "${ROOT}"/usr/$(get_libdir)/python*; do
157 PYTHON_MODNAME="${PN}" 194 PYTHON_MODNAME="${PN}"
158 fi 195 fi
159 done 196 done
160 fi 197 fi
161 198
162 if [[ -n "${PYTHON_MODNAME}" ]]; then 199 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
163 for pymod in ${PYTHON_MODNAME}; do 200 for pymod in ${PYTHON_MODNAME}; do
164 for pylibdir in "${ROOT}"/usr/$(get_libdir)/python*; do
165 if [[ -d "${pylibdir}/site-packages/${pymod}" ]]; then
166 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
167 python_mod_cleanup "${pymod}" 201 python_mod_optimize "${pymod}"
168 else
169 python_mod_cleanup "${pylibdir#${ROOT}}/site-packages/${pymod}"
170 fi
171 fi
172 done 202 done
173 done
174 else 203 else
175 python_mod_cleanup 204 for pymod in ${PYTHON_MODNAME}; do
205 python_mod_optimize "$(python_get_sitedir)/${pymod}"
206 done
176 fi 207 fi
177} 208}
178 209
179# @FUNCTION: distutils_pkg_postinst 210# @FUNCTION: distutils_pkg_postrm
180# @DESCRIPTION: 211# @DESCRIPTION:
181# This is a generic optimization, you should override it if your package 212# Generic pyc/pyo cleanup script. This function is exported.
182# installs modules in another directory. This function is exported.
183distutils_pkg_postinst() { 213distutils_pkg_postrm() {
184 if [[ "${EBUILD_PHASE}" != "postinst" ]]; then 214 if [[ "${EBUILD_PHASE}" != "postrm" ]]; then
185 die "${FUNCNAME}() can be used only in pkg_postinst() phase" 215 die "${FUNCNAME}() can be used only in pkg_postrm() phase"
186 fi 216 fi
187 217
188 local pylibdir pymod 218 local pylibdir pymod
189 if [[ -z "${PYTHON_MODNAME}" ]]; then 219 if [[ -z "${PYTHON_MODNAME}" ]]; then
190 for pylibdir in "${ROOT}"/usr/$(get_libdir)/python*; do 220 for pylibdir in "${ROOT}"/usr/$(get_libdir)/python*; do
192 PYTHON_MODNAME="${PN}" 222 PYTHON_MODNAME="${PN}"
193 fi 223 fi
194 done 224 done
195 fi 225 fi
196 226
197 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then 227 if [[ -n "${PYTHON_MODNAME}" ]]; then
198 for pymod in ${PYTHON_MODNAME}; do 228 for pymod in ${PYTHON_MODNAME}; do
229 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
199 python_mod_optimize "${pymod}" 230 python_mod_cleanup "${pymod}"
231 else
232 for pylibdir in "${ROOT}"/usr/$(get_libdir)/python*; do
233 if [[ -d "${pylibdir}/site-packages/${pymod}" ]]; then
234 python_mod_cleanup "${pylibdir#${ROOT}}/site-packages/${pymod}"
235 fi
200 done 236 done
201 else 237 fi
202 python_version
203 for pymod in ${PYTHON_MODNAME}; do
204 python_mod_optimize "/usr/$(get_libdir)/python${PYVER}/site-packages/${pymod}"
205 done 238 done
239 else
240 python_mod_cleanup
206 fi 241 fi
207} 242}
208 243
209# @FUNCTION: distutils_python_version 244# @FUNCTION: distutils_python_version
210# @DESCRIPTION: 245# @DESCRIPTION:

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

  ViewVC Help
Powered by ViewVC 1.1.20