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

Diff of /eclass/python.eclass

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

Revision 1.34 Revision 1.35
1# Copyright 1999-2008 Gentoo Foundation 1# Copyright 1999-2008 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/python.eclass,v 1.34 2008/03/28 07:11:57 hawking Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.35 2008/05/29 14:10:48 hawking Exp $
4 4
5# @ECLASS: python.eclass 5# @ECLASS: python.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# python@gentoo.org 7# python@gentoo.org
8# 8#
122 fi 122 fi
123 return 0 123 return 0
124} 124}
125 125
126# @FUNCTION: python_mod_compile 126# @FUNCTION: python_mod_compile
127# @USAGE: < file > 127# @USAGE: < file > [more files ...]
128# @DESCRIPTION: 128# @DESCRIPTION:
129# Given a filename, it will pre-compile the module's .pyc and .pyo. 129# Given filenames, it will pre-compile the module's .pyc and .pyo.
130# should only be run in pkg_postinst() 130# should only be run in pkg_postinst()
131# 131#
132# Example: 132# Example:
133# python_mod_compile ${ROOT}usr/lib/python2.3/site-packages/pygoogle.py 133# python_mod_compile /usr/lib/python2.3/site-packages/pygoogle.py
134# 134#
135python_mod_compile() { 135python_mod_compile() {
136 local f myroot
136 # allow compiling for older python versions 137 # allow compiling for older python versions
137 if [ -n "${PYTHON_OVERRIDE_PYVER}" ]; then 138 if [ -n "${PYTHON_OVERRIDE_PYVER}" ]; then
138 PYVER=${PYTHON_OVERRIDE_PYVER} 139 PYVER=${PYTHON_OVERRIDE_PYVER}
139 else 140 else
140 python_version 141 python_version
141 fi 142 fi
142 143
144 # strip trailing slash
145 myroot="${ROOT%/}"
146
147 # respect ROOT
148 for f in $@; do
149 [ -f "${myroot}/${f}" ] && myfiles="${myfiles} ${myroot}/${f}"
150 done
151
143 if [ -f "$1" ]; then 152 if [ -n "${myfiles}" ]; then
144 python${PYVER} -c "import py_compile; py_compile.compile('${1}')" || \ 153 python${PYVER} ${myroot}/usr/$(get_libdir)/python${PYVER}/py_compile.py ${myfiles}
154 python${PYVER} -O ${myroot}/usr/$(get_libdir)/python${PYVER}/py_compile.py ${myfiles}
155 else
145 ewarn "Failed to compile ${1}" 156 ewarn "No files to compile!"
146 python${PYVER} -O -c "import py_compile; py_compile.compile('${1}')" || \
147 ewarn "Failed to compile ${1}"
148 else
149 ewarn "Unable to find ${1}"
150 fi 157 fi
151} 158}
152 159
153# @FUNCTION: python_mod_optimize 160# @FUNCTION: python_mod_optimize
154# @USAGE: [ path ] 161# @USAGE: [ path ]

Legend:
Removed from v.1.34  
changed lines
  Added in v.1.35

  ViewVC Help
Powered by ViewVC 1.1.20