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

Diff of /eclass/distutils.eclass

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

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

Legend:
Removed from v.1.60  
changed lines
  Added in v.1.65

  ViewVC Help
Powered by ViewVC 1.1.20