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

Diff of /eclass/python.eclass

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

Revision 1.5 Revision 1.6
1# Copyright 1999-2003 Gentoo Technologies, Inc. 1# Copyright 1999-2003 Gentoo Technologies, Inc.
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.5 2003/10/17 07:14:26 liquidx Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.6 2003/10/23 23:15:57 liquidx Exp $
4# 4#
5# Author: Alastair Tse <liquidx@gentoo.org> 5# Author: Alastair Tse <liquidx@gentoo.org>
6# 6#
7# A Utility Eclass that should be inherited by anything that deals with 7# A Utility Eclass that should be inherited by anything that deals with
8# Python or Python modules. 8# Python or Python modules.
15# python_mod_optimize() - Generates .pyc/.pyo precompiled scripts 15# python_mod_optimize() - Generates .pyc/.pyo precompiled scripts
16# python_mod_cleanup() - Goes through /usr/lib/python* to remove 16# python_mod_cleanup() - Goes through /usr/lib/python* to remove
17# orphaned *.pyc *.pyo 17# orphaned *.pyc *.pyo
18# python_makesym() - Makes /usr/bin/python symlinks 18# python_makesym() - Makes /usr/bin/python symlinks
19 19
20inherit alternatives 20inherit alternatives virtualx
21 21
22ECLASS="python" 22ECLASS="python"
23INHERITED="$INHERITED $ECLASS" 23INHERITED="$INHERITED $ECLASS"
24 24
25# 25#
85# name: python_mod_exists 85# name: python_mod_exists
86# desc: run with the module name as an argument. it will check if a 86# desc: run with the module name as an argument. it will check if a
87# python module is installed and loadable. it will return 87# python module is installed and loadable. it will return
88# TRUE(0) if the module exists, and FALSE(1) if the module does 88# TRUE(0) if the module exists, and FALSE(1) if the module does
89# not exist. 89# not exist.
90#
91# note: we use virtualmake from virtualx.eclass to get around
92# when people build without X available. some packages like
93# pygtk need X avaiable when being imported.
94#
90# exam: 95# exam:
91# if python_mod_exists gtk; then 96# if python_mod_exists gtk; then
92# echo "gtk support enabled 97# echo "gtk support enabled
93# fi 98# fi
94# 99#
95python_mod_exists() { 100python_mod_exists() {
101 export maketype="python"
96 if ! python -c "import $1" >/dev/null 2>&1; then 102 if ! virtualmake -c "import $1" >/dev/null 2>&1; then
97 return 1 103 return 1
98 fi 104 fi
99 return 0 105 return 0
100} 106}
101 107
178 done 184 done
179 fi 185 fi
180 186
181 for path in ${SEARCH_PATH}; do 187 for path in ${SEARCH_PATH}; do
182 einfo "Searching ${path} .." 188 einfo "Searching ${path} .."
183 for obj in $(find ${path} -name *.pyc); do 189 for obj in $(find ${path} -name *.pyc | sort -r); do
184 src_py="$(echo $obj | sed 's:c$::')" 190 src_py="$(echo $obj | sed 's:c$::')"
185 if [ ! -f "${src_py}" ]; then 191 if [ ! -f "${src_py}" ]; then
186 einfo "Purging ${src_py}[co]" 192 einfo "Purging ${src_py}[co]"
187 rm -f ${src_py}[co] 193 rm -f ${src_py}[co]
194 # clean up directory if it is empty
195 current_dir="`dirname ${obj}`"
196 if [ `ls -1 --color=none $current_dir | wc -l 2> /dev/null` -lt 1 ]; then
197 rmdir -f ${current_dir}
198 fi
188 fi 199 fi
189 done 200 done
190 done 201 done
191} 202}
192 203

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

  ViewVC Help
Powered by ViewVC 1.1.20