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.68 2009/12/24 04:21:39 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 | |
27 | if [[ -z "${DISTUTILS_DISABLE_PYTHON_DEPENDENCY}" ]]; then |
27 | if [[ -z "${DISTUTILS_DISABLE_PYTHON_DEPENDENCY}" ]]; then |
28 | DEPEND="virtual/python" |
28 | DEPEND="virtual/python" |
29 | RDEPEND="${DEPEND}" |
29 | RDEPEND="${DEPEND}" |
30 | fi |
30 | fi |
|
|
31 | |
|
|
32 | if has "${EAPI:-0}" 0 1 2; then |
31 | python="python" |
33 | python="python" |
|
|
34 | else |
|
|
35 | python="die" |
|
|
36 | fi |
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 | |
… | |
… | |
151 | |
161 | |
152 | # Mark the package to be rebuilt after a python upgrade. |
162 | # Mark the package to be rebuilt after a python upgrade. |
153 | python_need_rebuild |
163 | python_need_rebuild |
154 | |
164 | |
155 | if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then |
165 | if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then |
|
|
166 | if [[ -z "${DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS}" && "${BASH_VERSINFO[0]}" -ge "4" ]]; then |
|
|
167 | declare -A wrapper_scripts=() |
|
|
168 | |
|
|
169 | rename_scripts_with_versioned_shebangs() { |
|
|
170 | if [[ -d "${D}usr/bin" ]]; then |
|
|
171 | cd "${D}usr/bin" |
|
|
172 | |
|
|
173 | local file |
|
|
174 | for file in *; do |
|
|
175 | if [[ -f "${file}" && ! "${file}" =~ [[:digit:]]+\.[[:digit:]]+$ && "$(head -n1 "${file}")" =~ ^'#!'.*python[[:digit:]]+\.[[:digit:]]+ ]]; then |
|
|
176 | mv "${file}" "${file}-${PYTHON_ABI}" || die "Renaming of '${file}' failed" |
|
|
177 | wrapper_scripts+=(["${D}usr/bin/${file}"]=) |
|
|
178 | fi |
|
|
179 | done |
|
|
180 | fi |
|
|
181 | } |
|
|
182 | fi |
|
|
183 | |
156 | if [[ -n "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]]; then |
184 | if [[ -n "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]]; then |
157 | installation() { |
185 | installation() { |
158 | _distutils_hook pre |
186 | _distutils_hook pre |
159 | |
187 | |
160 | # need this for python-2.5 + setuptools in cases where |
188 | # need this for python-2.5 + setuptools in cases where |
… | |
… | |
165 | [[ -n "${pylibdir}" ]] && dodir "${pylibdir}" |
193 | [[ -n "${pylibdir}" ]] && dodir "${pylibdir}" |
166 | |
194 | |
167 | echo "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@" |
195 | 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 "$?" |
196 | "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@" || return "$?" |
169 | |
197 | |
|
|
198 | if [[ -z "${DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS}" && "${BASH_VERSINFO[0]}" -ge "4" ]]; then |
|
|
199 | rename_scripts_with_versioned_shebangs |
|
|
200 | fi |
|
|
201 | |
170 | _distutils_hook post |
202 | _distutils_hook post |
171 | } |
203 | } |
172 | python_execute_function -s installation "$@" |
204 | python_execute_function -s installation "$@" |
173 | else |
205 | else |
174 | installation() { |
206 | installation() { |
… | |
… | |
182 | [[ -n "${pylibdir}" ]] && dodir "${pylibdir}" |
214 | [[ -n "${pylibdir}" ]] && dodir "${pylibdir}" |
183 | |
215 | |
184 | echo "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build -b "build-${PYTHON_ABI}" install --root="${D}" --no-compile "$@" |
216 | 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 "$?" |
217 | "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build -b "build-${PYTHON_ABI}" install --root="${D}" --no-compile "$@" || return "$?" |
186 | |
218 | |
|
|
219 | if [[ -z "${DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS}" && "${BASH_VERSINFO[0]}" -ge "4" ]]; then |
|
|
220 | rename_scripts_with_versioned_shebangs |
|
|
221 | fi |
|
|
222 | |
187 | _distutils_hook post |
223 | _distutils_hook post |
188 | } |
224 | } |
189 | python_execute_function installation "$@" |
225 | python_execute_function installation "$@" |
190 | fi |
226 | fi |
|
|
227 | |
|
|
228 | if [[ -z "${DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS}" && "${#wrapper_scripts[@]}" -ne "0" && "${BASH_VERSINFO[0]}" -ge "4" ]]; then |
|
|
229 | python_generate_wrapper_scripts "${!wrapper_scripts[@]}" |
|
|
230 | fi |
|
|
231 | unset wrapper_scripts |
191 | else |
232 | else |
192 | # need this for python-2.5 + setuptools in cases where |
233 | # need this for python-2.5 + setuptools in cases where |
193 | # a package uses distutils but does not install anything |
234 | # a package uses distutils but does not install anything |
194 | # in site-packages. (eg. dev-java/java-config-2.x) |
235 | # in site-packages. (eg. dev-java/java-config-2.x) |
195 | # - liquidx (14/08/2006) |
236 | # - liquidx (14/08/2006) |
… | |
… | |
281 | # @FUNCTION: distutils_python_version |
322 | # @FUNCTION: distutils_python_version |
282 | # @DESCRIPTION: |
323 | # @DESCRIPTION: |
283 | # Calls python_version, so that you can use something like |
324 | # Calls python_version, so that you can use something like |
284 | # e.g. insinto ${ROOT}/usr/include/python${PYVER} |
325 | # e.g. insinto ${ROOT}/usr/include/python${PYVER} |
285 | distutils_python_version() { |
326 | distutils_python_version() { |
|
|
327 | if ! has "${EAPI:-0}" 0 1 2; then |
|
|
328 | die "${FUNCNAME}() cannot be used in this EAPI" |
|
|
329 | fi |
|
|
330 | |
286 | python_version |
331 | python_version |
287 | } |
332 | } |
288 | |
333 | |
289 | # @FUNCTION: distutils_python_tkinter |
334 | # @FUNCTION: distutils_python_tkinter |
290 | # @DESCRIPTION: |
335 | # @DESCRIPTION: |
291 | # Checks for if tkinter support is compiled into python |
336 | # Checks for if tkinter support is compiled into python |
292 | distutils_python_tkinter() { |
337 | distutils_python_tkinter() { |
|
|
338 | if ! has "${EAPI:-0}" 0 1 2; then |
|
|
339 | die "${FUNCNAME}() cannot be used in this EAPI" |
|
|
340 | fi |
|
|
341 | |
293 | python_tkinter_exists |
342 | python_tkinter_exists |
294 | } |
343 | } |