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

Diff of /eclass/python-distutils-ng.eclass

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

Revision 1.8 Revision 1.14
1# Copyright 1999-2012 Gentoo Foundation 1# Copyright 1999-2012 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/Attic/python-distutils-ng.eclass,v 1.8 2012/03/28 14:21:55 marienz Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/Attic/python-distutils-ng.eclass,v 1.14 2012/05/02 21:40:42 floppym Exp $
4 4
5# @ECLASS: python-distutils-ng 5# @ECLASS: python-distutils-ng
6# @MAINTAINER: 6# @MAINTAINER:
7# Python herd <python@gentoo.org> 7# Python herd <python@gentoo.org>
8# @AUTHOR: 8# @AUTHOR:
23# each implementation, default function will run `setup.py build' 23# each implementation, default function will run `setup.py build'
24# - src_test - you can define python_test function that will be run for each 24# - src_test - you can define python_test function that will be run for each
25# implementation 25# implementation
26# - src_install - you can define python_install function that will be run for 26# - src_install - you can define python_install function that will be run for
27# each implementation and python_install_all that will be run in original 27# each implementation and python_install_all that will be run in original
28# directory (so it wil lnot contain any implementation-specific files) 28# directory (so it will not contain any implementation-specific files)
29 29
30# @ECLASS-VARIABLE: PYTHON_COMPAT 30# @ECLASS-VARIABLE: PYTHON_COMPAT
31# @DESCRIPTION: 31# @DESCRIPTION:
32# This variable contains a space separated list of implementations (see above) a 32# This variable contains a space separated list of implementations (see above) a
33# package is compatible to. It must be set before the `inherit' call. The 33# package is compatible to. It must be set before the `inherit' call. The
49# @ECLASS-VARIABLE: PYTHON_DISABLE_COMPILATION 49# @ECLASS-VARIABLE: PYTHON_DISABLE_COMPILATION
50# @DESCRIPTION: 50# @DESCRIPTION:
51# Set the value to "yes" to skip compilation and/or optimization of Python 51# Set the value to "yes" to skip compilation and/or optimization of Python
52# modules. 52# modules.
53 53
54EXPORT_FUNCTIONS src_prepare src_configure src_compile src_test src_install 54EXPORT_FUNCTIONS pkg_pretend src_prepare src_configure src_compile src_test src_install
55 55
56case "${EAPI}" in 56case "${EAPI}" in
57 0|1|2|3) 57 0|1|2|3)
58 die "Unsupported EAPI=${EAPI} (too old) for python-distutils-ng.eclass" ;; 58 die "Unsupported EAPI=${EAPI} (too old) for python-distutils-ng.eclass" ;;
59 4) 59 4)
200 python?_?) 200 python?_?)
201 return 0 ;; 201 return 0 ;;
202 *) 202 *)
203 return 1 ;; 203 return 1 ;;
204 esac 204 esac
205}
206
207# @FUNCTION: python-distutils-ng_redoscript
208# @USAGE: script_file_path [destination_directory]
209# @DESCRIPTION:
210# Reinstall script installed already by setup.py. This works by first moving the
211# script to ${T} directory and later running python-distutils-ng_doscript on it.
212# script_file_path has to be a full path relative to ${D}.
213python-distutils-ng_redoscript() {
214 local sbn="$(basename "${1}")"
215 mkdir -p "${T}/_${sbn}/" || die "failed to create directory"
216 mv "${D}/${1}" "${T}/_${sbn}/${sbn}" || die "failed to move file"
217 python-distutils-ng_doscript "${T}/_${sbn}/${sbn}" "${2}"
205} 218}
206 219
207# @FUNCTION: python-distutils-ng_doscript 220# @FUNCTION: python-distutils-ng_doscript
208# @USAGE: script_file_name [destination_directory] 221# @USAGE: script_file_name [destination_directory]
209# @DESCRIPTION: 222# @DESCRIPTION:
255 use "python_targets_${impl}" || continue 268 use "python_targets_${impl}" || continue
256 default_impl="${impl}" 269 default_impl="${impl}"
257 break 270 break
258 done 271 done
259 else 272 else
260 use "python_targets_${impl}" || \ 273 use "python_targets_${default_impl}" || \
261 die "default implementation ${default_impl} not enabled" 274 die "default implementation ${default_impl} not enabled"
262 fi 275 fi
263 276
264 [[ -n "${default_impl}" ]] || die "Could not select default implementation" 277 [[ -n "${default_impl}" ]] || die "Could not select default implementation"
265 278
286 299
287 dosym "${destination_file}-${default_impl}" "${destination_directory}/${destination_file}" 300 dosym "${destination_file}-${default_impl}" "${destination_directory}/${destination_file}"
288 fi 301 fi
289} 302}
290 303
304# Phase function: pkg_pretend
305python-distutils-ng_pkg_pretend() {
306 if has "collision-protect" ${FEATURES}; then
307 ewarn "Due to previous eclass compiling Python files outside of src_install"
308 ewarn "(and not recording resulting .pyc and .pyo files as owned by any package)"
309 ewarn "merging this package with \"collision-protect\" in FEATURES may result"
310 ewarn "in an error, please switch to using \"protect-owned\" instead."
311 fi
312}
313
291# Phase function: src_prepare 314# Phase function: src_prepare
292python-distutils-ng_src_prepare() { 315python-distutils-ng_src_prepare() {
293 [[ "${PYTHON_OPTIONAL}" = "yes" ]] && { use python || return; } 316 [[ "${PYTHON_OPTIONAL}" = "yes" ]] && { use python || return; }
294 317
295 # Try to run binary for each implementation: 318 # Try to run binary for each implementation:
362 fi 385 fi
363 386
364 S="${WORKDIR}/${_PACKAGE_SPECIFIC_S}" 387 S="${WORKDIR}/${_PACKAGE_SPECIFIC_S}"
365 if type python_install_all &> /dev/null; then 388 if type python_install_all &> /dev/null; then
366 einfo "Running python_install_all in ${S} for all" 389 einfo "Running python_install_all in ${S} for all"
390 pushd "${S}" &> /dev/null
367 python_install_all 391 python_install_all
392 popd &> /dev/null
368 fi 393 fi
369 394
370 for impl in ${PYTHON_COMPAT}; do 395 for impl in ${PYTHON_COMPAT}; do
371 [[ "${PYTHON_DISABLE_COMPILATION}" = "yes" ]] && continue 396 [[ "${PYTHON_DISABLE_COMPILATION}" = "yes" ]] && continue
372 use "python_targets_${impl}" ${PYTHON_COMPAT} || continue 397 use "python_targets_${impl}" ${PYTHON_COMPAT} || continue
373 398
374 PYTHON="$(_python-distutils-ng_get_binary_for_implementation "${impl}")" 399 PYTHON="$(_python-distutils-ng_get_binary_for_implementation "${impl}")"
375 for accessible_path in $(${PYTHON} -c 'import sys; print " ".join(sys.path)'); do 400 for accessible_path in $(${PYTHON} -c 'import sys; print(" ".join(sys.path))'); do
376 [[ -d "${D}/${accessible_path}" ]] || continue 401 [[ -d "${D}/${accessible_path}" ]] || continue
377 402
378 _python-distutils-ng_has_compileall "${impl}" || continue 403 _python-distutils-ng_has_compileall "${impl}" || continue
379 ebegin "Compiling ${accessible_path} for ${impl}" 404 ebegin "Compiling ${accessible_path} for ${impl}"
380 ${PYTHON} \ 405 ${PYTHON} \

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.14

  ViewVC Help
Powered by ViewVC 1.1.20