/[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.15 Revision 1.16
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.15 2012/05/03 00:31:58 floppym Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/Attic/python-distutils-ng.eclass,v 1.16 2012/05/04 08:31:43 nelchael 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:
169 169
170# @FUNCTION: _python-distutils-ng_default_distutils_install 170# @FUNCTION: _python-distutils-ng_default_distutils_install
171# @DESCRIPTION: 171# @DESCRIPTION:
172# Default src_install for distutils-based packages. 172# Default src_install for distutils-based packages.
173_python-distutils-ng_default_distutils_install() { 173_python-distutils-ng_default_distutils_install() {
174 "${PYTHON}" setup.py install --no-compile --root="${D}/" || die 174 local compile_flags="--compile -O2"
175}
176 175
177# @FUNCTION: _python-distutils-ng_has_compileall
178# @USAGE: implementation
179# @RETURN: 0 if given implementation has compileall module
180# @DESCRIPTION:
181# This function is used to decide whenever to compile Python modules for given
182# implementation.
183_python-distutils-ng_has_compileall() {
184 case "${1}" in 176 case "${1}" in
185 python?_?|jython?_?) 177 jython*)
186 return 0 ;; 178 # Jython does not support optimizations
187 *) 179 compile_flags="--compile" ;;
188 return 1 ;;
189 esac 180 esac
190}
191 181
192# @FUNCTION: _python-distutils-ng_has_compileall_opt 182 unset PYTHONDONTWRITEBYTECODE
193# @USAGE: implementation 183 [[ -n "${PYTHON_DISABLE_COMPILATION}" ]] && compile_flags="--no-compile"
194# @RETURN: 0 if given implementation has compileall module and supports # optimizations 184 "${PYTHON}" setup.py install ${compile_flags} --root="${D%/}/" || die
195# @DESCRIPTION:
196# This function is used to decide whenever to compile and optimize Python
197# modules for given implementation.
198_python-distutils-ng_has_compileall_opt() {
199 case "${1}" in
200 python?_?)
201 return 0 ;;
202 *)
203 return 1 ;;
204 esac
205} 185}
206 186
207# @FUNCTION: python-distutils-ng_redoscript 187# @FUNCTION: python-distutils-ng_redoscript
208# @USAGE: script_file_path [destination_directory] 188# @USAGE: script_file_path [destination_directory]
209# @DESCRIPTION: 189# @DESCRIPTION:
388 einfo "Running python_install_all in ${S} for all" 368 einfo "Running python_install_all in ${S} for all"
389 pushd "${S}" &> /dev/null 369 pushd "${S}" &> /dev/null
390 python_install_all 370 python_install_all
391 popd &> /dev/null 371 popd &> /dev/null
392 fi 372 fi
393
394 for impl in ${PYTHON_COMPAT}; do
395 [[ "${PYTHON_DISABLE_COMPILATION}" = "yes" ]] && continue
396 use "python_targets_${impl}" ${PYTHON_COMPAT} || continue
397
398 PYTHON="$(_python-distutils-ng_get_binary_for_implementation "${impl}")"
399 for accessible_path in $(${PYTHON} -c 'import sys; print(" ".join(sys.path))'); do
400 [[ -d "${D}/${accessible_path}" ]] || continue
401
402 _python-distutils-ng_has_compileall "${impl}" || continue
403 ebegin "Compiling ${accessible_path} for ${impl}"
404 ${PYTHON} \
405 -m compileall -q -f "${D}/${accessible_path}" || die
406 eend $?
407
408 _python-distutils-ng_has_compileall_opt "${impl}" || continue
409 ebegin "Optimizing ${accessible_path} for ${impl}"
410 PYTHONOPTIMIZE=1 ${PYTHON} \
411 -m compileall -q -f "${D}/${accessible_path}" || die
412 eend $?
413 done;
414 done
415} 373}

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16

  ViewVC Help
Powered by ViewVC 1.1.20