| 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/distutils.eclass,v 1.46 2008/02/28 20:20:32 dev-zero Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/distutils.eclass,v 1.54 2008/10/28 21:29:28 hawking Exp $ |
| 4 | |
4 | |
| 5 | # @ECLASS: distutils.eclass |
5 | # @ECLASS: distutils.eclass |
| 6 | # @MAINTAINER: |
6 | # @MAINTAINER: |
| 7 | # Alastair Tse <liquidx@gentoo.org> |
7 | # <python@gentoo.org> |
| 8 | # |
8 | # |
| 9 | # Original author: Jon Nelson <jnelson@gentoo.org> |
9 | # Original author: Jon Nelson <jnelson@gentoo.org> |
| 10 | # @BLURB: This eclass allows easier installation of distutils-based python modules |
10 | # @BLURB: This eclass allows easier installation of distutils-based python modules |
| 11 | # @DESCRIPTION: |
11 | # @DESCRIPTION: |
| 12 | # The distutils eclass is designed to allow easier installation of |
12 | # The distutils eclass is designed to allow easier installation of |
| … | |
… | |
| 61 | # The distutils src_install function, this function is exported. |
61 | # The distutils src_install function, this function is exported. |
| 62 | # It also installs the "standard docs" (CHANGELOG, Change*, KNOWN_BUGS, MAINTAINERS, |
62 | # It also installs the "standard docs" (CHANGELOG, Change*, KNOWN_BUGS, MAINTAINERS, |
| 63 | # PKG-INFO, CONTRIBUTORS, TODO, NEWS, MANIFEST*, README*, and AUTHORS) |
63 | # PKG-INFO, CONTRIBUTORS, TODO, NEWS, MANIFEST*, README*, and AUTHORS) |
| 64 | distutils_src_install() { |
64 | distutils_src_install() { |
| 65 | |
65 | |
|
|
66 | # Mark the package to be rebuilt after a python upgrade. |
|
|
67 | python_need_rebuild |
|
|
68 | |
| 66 | # need this for python-2.5 + setuptools in cases where |
69 | # need this for python-2.5 + setuptools in cases where |
| 67 | # a package uses distutils but does not install anything |
70 | # a package uses distutils but does not install anything |
| 68 | # in site-packages. (eg. dev-java/java-config-2.x) |
71 | # in site-packages. (eg. dev-java/java-config-2.x) |
| 69 | # - liquidx (14/08/2006) |
72 | # - liquidx (14/08/2006) |
| 70 | pylibdir="$(${python} -c 'from distutils.sysconfig import get_python_lib; print get_python_lib()')" |
73 | pylibdir="$(${python} -c 'from distutils.sysconfig import get_python_lib; print get_python_lib()')" |
| 71 | [ -n "${pylibdir}" ] && dodir "${pylibdir}" |
74 | [ -n "${pylibdir}" ] && dodir "${pylibdir}" |
| 72 | |
75 | |
| 73 | if has_version ">=dev-lang/python-2.3"; then |
76 | if has_version ">=dev-lang/python-2.3"; then |
| 74 | ${python} setup.py install --root=${D} --no-compile "$@" || die |
77 | ${python} setup.py install --root="${D}" --no-compile "$@" ||\ |
|
|
78 | die "python setup.py install failed" |
| 75 | else |
79 | else |
| 76 | ${python} setup.py install --root=${D} "$@" || die |
80 | ${python} setup.py install --root="${D}" "$@" ||\ |
|
|
81 | die "python setup.py install failed" |
| 77 | fi |
82 | fi |
| 78 | |
83 | |
| 79 | DDOCS="CHANGELOG KNOWN_BUGS MAINTAINERS PKG-INFO CONTRIBUTORS TODO NEWS" |
84 | DDOCS="CHANGELOG KNOWN_BUGS MAINTAINERS PKG-INFO CONTRIBUTORS TODO NEWS" |
| 80 | DDOCS="${DDOCS} Change* MANIFEST* README* AUTHORS" |
85 | DDOCS="${DDOCS} Change* MANIFEST* README* AUTHORS" |
| 81 | |
86 | |
| … | |
… | |
| 88 | |
93 | |
| 89 | # @FUNCTION: distutils_pkg_postrm |
94 | # @FUNCTION: distutils_pkg_postrm |
| 90 | # @DESCRIPTION: |
95 | # @DESCRIPTION: |
| 91 | # Generic pyc/pyo cleanup script. This function is exported. |
96 | # Generic pyc/pyo cleanup script. This function is exported. |
| 92 | distutils_pkg_postrm() { |
97 | distutils_pkg_postrm() { |
| 93 | PYTHON_MODNAME=${PYTHON_MODNAME:-${PN}} |
98 | local moddir pylibdir pymod |
|
|
99 | if [[ -z "${PYTHON_MODNAME}" ]]; then |
|
|
100 | for pylibdir in "${ROOT}"/usr/$(get_libdir)/python*; do |
|
|
101 | if [[ -d "${pylibdir}"/site-packages/${PN} ]]; then |
|
|
102 | PYTHON_MODNAME=${PN} |
|
|
103 | fi |
|
|
104 | done |
|
|
105 | fi |
| 94 | |
106 | |
| 95 | if has_version ">=dev-lang/python-2.3"; then |
107 | if has_version ">=dev-lang/python-2.3"; then |
| 96 | ebegin "Performing Python Module Cleanup .." |
108 | ebegin "Performing Python Module Cleanup .." |
| 97 | if [ -n "${PYTHON_MODNAME}" ]; then |
109 | if [[ -n "${PYTHON_MODNAME}" ]]; then |
| 98 | for pymod in ${PYTHON_MODNAME}; do |
110 | for pymod in ${PYTHON_MODNAME}; do |
| 99 | for moddir in "`ls -d --color=none -1 ${ROOT}usr/$(get_libdir)/python*/site-packages/${pymod} 2> /dev/null`"; do |
111 | for pylibdir in "${ROOT}"/usr/$(get_libdir)/python*; do |
| 100 | python_mod_cleanup ${moddir} |
112 | if [[ -d "${pylibdir}"/site-packages/${pymod} ]]; then |
|
|
113 | python_mod_cleanup "${pylibdir#${ROOT}}"/site-packages/${pymod} |
|
|
114 | fi |
| 101 | done |
115 | done |
| 102 | done |
116 | done |
| 103 | else |
117 | else |
| 104 | python_mod_cleanup |
118 | python_mod_cleanup |
| 105 | fi |
119 | fi |
| … | |
… | |
| 110 | # @FUNCTION: distutils_pkg_postinst |
124 | # @FUNCTION: distutils_pkg_postinst |
| 111 | # @DESCRIPTION: |
125 | # @DESCRIPTION: |
| 112 | # This is a generic optimization, you should override it if your package |
126 | # This is a generic optimization, you should override it if your package |
| 113 | # installs things in another directory. This function is exported |
127 | # installs things in another directory. This function is exported |
| 114 | distutils_pkg_postinst() { |
128 | distutils_pkg_postinst() { |
| 115 | PYTHON_MODNAME=${PYTHON_MODNAME:-${PN}} |
129 | local pylibdir pymod |
| 116 | |
130 | if [[ -z "${PYTHON_MODNAME}" ]]; then |
| 117 | # strip trailing slash |
131 | for pylibdir in "${ROOT}"/usr/$(get_libdir)/python*; do |
| 118 | myroot="${ROOT%/}" |
132 | if [[ -d "${pylibdir}"/site-packages/${PN} ]]; then |
|
|
133 | PYTHON_MODNAME=${PN} |
|
|
134 | fi |
|
|
135 | done |
|
|
136 | fi |
| 119 | |
137 | |
| 120 | if has_version ">=dev-lang/python-2.3"; then |
138 | if has_version ">=dev-lang/python-2.3"; then |
| 121 | python_version |
139 | python_version |
| 122 | for pymod in ${PYTHON_MODNAME}; do |
140 | for pymod in ${PYTHON_MODNAME}; do |
|
|
141 | python_mod_optimize \ |
| 123 | if [ -d "${myroot}/usr/$(get_libdir)/python${PYVER}/site-packages/${pymod}" ]; then |
142 | /usr/$(get_libdir)/python${PYVER}/site-packages/${pymod} |
| 124 | python_mod_optimize ${myroot}/usr/$(get_libdir)/python${PYVER}/site-packages/${pymod} |
|
|
| 125 | fi |
|
|
| 126 | done |
143 | done |
| 127 | fi |
144 | fi |
| 128 | } |
145 | } |
| 129 | |
146 | |
| 130 | # @FUNCTION: distutils_python_version |
147 | # @FUNCTION: distutils_python_version |