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

Diff of /eclass/python.eclass

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

Revision 1.90 Revision 1.91
1# Copyright 1999-2010 Gentoo Foundation 1# Copyright 1999-2010 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.90 2010/02/28 11:48:40 arfrever Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.91 2010/02/28 15:49:33 arfrever Exp $
4 4
5# @ECLASS: python.eclass 5# @ECLASS: python.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# Gentoo Python Project <python@gentoo.org> 7# Gentoo Python Project <python@gentoo.org>
8# @BLURB: Eclass for Python packages 8# @BLURB: Eclass for Python packages
1475 1475
1476 # Delete potential whitespace after "#!". 1476 # Delete potential whitespace after "#!".
1477 sed -e '1s/\(^#!\)[[:space:]]*/\1/' -i "${file}" || die "sed '${file}' failed" 1477 sed -e '1s/\(^#!\)[[:space:]]*/\1/' -i "${file}" || die "sed '${file}' failed"
1478 fi 1478 fi
1479 done 1479 done
1480}
1481
1482# @FUNCTION: python_mod_exists
1483# @USAGE: <module>
1484# @DESCRIPTION:
1485# Run with the module name as an argument. It will check if a
1486# Python module is installed and loadable. It will return
1487# TRUE(0) if the module exists, and FALSE(1) if the module does
1488# not exist.
1489#
1490# Example:
1491# if python_mod_exists gtk; then
1492# echo "gtk support enabled"
1493# fi
1494python_mod_exists() {
1495 if [[ "$#" -ne 1 ]]; then
1496 die "${FUNCNAME}() requires 1 argument"
1497 fi
1498 "$(PYTHON ${PYTHON_ABI})" -c "import $1" &> /dev/null
1499} 1480}
1500 1481
1501# ================================================================================================ 1482# ================================================================================================
1502# ================================ FUNCTIONS FOR RUNNING OF TESTS ================================ 1483# ================================ FUNCTIONS FOR RUNNING OF TESTS ================================
1503# ================================================================================================ 1484# ================================================================================================
2010 export PYVER_MICRO="${PYVER_ALL:4}" 1991 export PYVER_MICRO="${PYVER_ALL:4}"
2011 fi 1992 fi
2012 export PYVER="${PYVER_MAJOR}.${PYVER_MINOR}" 1993 export PYVER="${PYVER_MAJOR}.${PYVER_MINOR}"
2013} 1994}
2014 1995
1996# @FUNCTION: python_mod_exists
1997# @USAGE: <module>
1998# @DESCRIPTION:
1999# Run with the module name as an argument. It will check if a
2000# Python module is installed and loadable. It will return
2001# TRUE(0) if the module exists, and FALSE(1) if the module does
2002# not exist.
2003#
2004# Example:
2005# if python_mod_exists gtk; then
2006# echo "gtk support enabled"
2007# fi
2008python_mod_exists() {
2009 if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
2010 eerror "Use USE dependencies and/or has_version() instead of ${FUNCNAME}()."
2011 die "${FUNCNAME}() cannot be used in this EAPI"
2012 fi
2013
2014 if [[ "$#" -ne 1 ]]; then
2015 die "${FUNCNAME}() requires 1 argument"
2016 fi
2017 "$(PYTHON ${PYTHON_ABI})" -c "import $1" &> /dev/null
2018}
2019
2015# @FUNCTION: python_tkinter_exists 2020# @FUNCTION: python_tkinter_exists
2016# @DESCRIPTION: 2021# @DESCRIPTION:
2017# Run without arguments, checks if Python was compiled with Tkinter 2022# Run without arguments, checks if Python was compiled with Tkinter
2018# support. If not, prints an error message and dies. 2023# support. If not, prints an error message and dies.
2019python_tkinter_exists() { 2024python_tkinter_exists() {

Legend:
Removed from v.1.90  
changed lines
  Added in v.1.91

  ViewVC Help
Powered by ViewVC 1.1.20