| 1 | # Copyright 1999-2008 Gentoo Foundation |
1 | # Copyright 1999-2009 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.54 2008/10/28 21:29:28 hawking Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/distutils.eclass,v 1.69 2010/01/10 17:24:32 arfrever Exp $ |
| 4 | |
4 | |
| 5 | # @ECLASS: distutils.eclass |
5 | # @ECLASS: distutils.eclass |
| 6 | # @MAINTAINER: |
6 | # @MAINTAINER: |
| 7 | # <python@gentoo.org> |
7 | # <python@gentoo.org> |
| 8 | # |
8 | # |
| … | |
… | |
| 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 |
| 13 | # distutils-based python modules and their incorporation into |
13 | # distutils-based python modules and their incorporation into |
| 14 | # the Gentoo Linux system. |
14 | # the Gentoo Linux system. |
| 15 | # |
|
|
| 16 | # It inherits python, multilib, and eutils |
|
|
| 17 | |
15 | |
| 18 | inherit python multilib eutils |
16 | inherit eutils multilib python |
| 19 | |
17 | |
| 20 | # @ECLASS-VARIABLE: PYTHON_SLOT_VERSION |
18 | case "${EAPI:-0}" in |
| 21 | # @DESCRIPTION: |
19 | 0|1) |
| 22 | # This helps make it possible to add extensions to python slots. |
20 | EXPORT_FUNCTIONS src_unpack src_compile src_install pkg_postinst pkg_postrm |
| 23 | # Normally only a -py21- ebuild would set PYTHON_SLOT_VERSION. |
21 | ;; |
| 24 | if [ "${PYTHON_SLOT_VERSION}" = "2.1" ] ; then |
22 | *) |
| 25 | DEPEND="=dev-lang/python-2.1*" |
23 | EXPORT_FUNCTIONS src_unpack src_prepare src_compile src_install pkg_postinst pkg_postrm |
|
|
24 | ;; |
|
|
25 | esac |
|
|
26 | |
|
|
27 | if [[ -z "${DISTUTILS_DISABLE_PYTHON_DEPENDENCY}" ]]; then |
|
|
28 | DEPEND="virtual/python" |
|
|
29 | RDEPEND="${DEPEND}" |
|
|
30 | fi |
|
|
31 | |
|
|
32 | if has "${EAPI:-0}" 0 1 2; then |
| 26 | python="python2.1" |
33 | python="python" |
| 27 | elif [ "${PYTHON_SLOT_VERSION}" = "2.3" ] ; then |
|
|
| 28 | DEPEND="=dev-lang/python-2.3*" |
|
|
| 29 | python="python2.3" |
|
|
| 30 | else |
34 | else |
| 31 | DEPEND="virtual/python" |
35 | python="die" |
| 32 | python="python" |
|
|
| 33 | fi |
36 | fi |
| 34 | |
37 | |
|
|
38 | # @ECLASS-VARIABLE: DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES |
|
|
39 | # @DESCRIPTION: |
|
|
40 | # Set this to use separate source directories for each enabled version of Python. |
|
|
41 | |
|
|
42 | # @ECLASS-VARIABLE: DISTUTILS_GLOBAL_OPTIONS |
|
|
43 | # @DESCRIPTION: |
|
|
44 | # Global options passed to setup.py. |
|
|
45 | |
|
|
46 | # @ECLASS-VARIABLE: DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS |
|
|
47 | # @DESCRIPTION: |
|
|
48 | # Set this to disable renaming of Python scripts containing versioned shebangs |
|
|
49 | # and generation of wrapper scripts. |
|
|
50 | |
| 35 | # @ECLASS-VARIABLE: DOCS |
51 | # @ECLASS-VARIABLE: DOCS |
| 36 | # @DESCRIPTION: |
52 | # @DESCRIPTION: |
| 37 | # Additional DOCS |
53 | # Additional DOCS |
| 38 | |
54 | |
|
|
55 | _distutils_hook() { |
|
|
56 | if [[ "$#" -ne 1 ]]; then |
|
|
57 | die "${FUNCNAME}() requires 1 argument" |
|
|
58 | fi |
|
|
59 | if [[ "$(type -t "distutils_src_${EBUILD_PHASE}_$1_hook")" == "function" ]]; then |
|
|
60 | "distutils_src_${EBUILD_PHASE}_$1_hook" |
|
|
61 | fi |
|
|
62 | } |
|
|
63 | |
| 39 | # @FUNCTION: distutils_src_unpack |
64 | # @FUNCTION: distutils_src_unpack |
| 40 | # @DESCRIPTION: |
65 | # @DESCRIPTION: |
| 41 | # The distutils src_unpack function, this function is exported |
66 | # The distutils src_unpack function, this function is exported. |
| 42 | distutils_src_unpack() { |
67 | distutils_src_unpack() { |
|
|
68 | if [[ "${EBUILD_PHASE}" != "unpack" ]]; then |
|
|
69 | die "${FUNCNAME}() can be used only in src_unpack() phase" |
|
|
70 | fi |
|
|
71 | |
| 43 | unpack ${A} |
72 | unpack ${A} |
| 44 | cd "${S}" |
73 | cd "${S}" |
| 45 | |
74 | |
| 46 | # remove ez_setup stuff to prevent packages |
75 | has "${EAPI:-0}" 0 1 && distutils_src_prepare |
| 47 | # from installing setuptools on their own |
76 | } |
|
|
77 | |
|
|
78 | # @FUNCTION: distutils_src_prepare |
|
|
79 | # @DESCRIPTION: |
|
|
80 | # The distutils src_prepare function, this function is exported. |
|
|
81 | distutils_src_prepare() { |
|
|
82 | if ! has "${EAPI:-0}" 0 1 && [[ "${EBUILD_PHASE}" != "prepare" ]]; then |
|
|
83 | die "${FUNCNAME}() can be used only in src_prepare() phase" |
|
|
84 | fi |
|
|
85 | |
|
|
86 | # Delete ez_setup files to prevent packages from installing |
|
|
87 | # Setuptools on their own. |
|
|
88 | local ez_setup_existence="0" |
|
|
89 | [[ -d ez_setup || -f ez_setup.py ]] && ez_setup_existence="1" |
| 48 | rm -rf ez_setup* |
90 | rm -fr ez_setup* |
|
|
91 | if [[ "${ez_setup_existence}" == "1" ]]; then |
| 49 | echo "def use_setuptools(*args, **kwargs): pass" > ez_setup.py |
92 | echo "def use_setuptools(*args, **kwargs): pass" > ez_setup.py |
|
|
93 | fi |
|
|
94 | |
|
|
95 | # Delete distribute_setup files to prevent packages from installing |
|
|
96 | # Distribute on their own. |
|
|
97 | local distribute_setup_existence="0" |
|
|
98 | [[ -d distribute_setup || -f distribute_setup.py ]] && distribute_setup_existence="1" |
|
|
99 | rm -fr distribute_setup* |
|
|
100 | if [[ "${distribute_setup_existence}" == "1" ]]; then |
|
|
101 | echo "def use_setuptools(*args, **kwargs): pass" > distribute_setup.py |
|
|
102 | fi |
|
|
103 | |
|
|
104 | if [[ -n "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]]; then |
|
|
105 | python_copy_sources |
|
|
106 | fi |
| 50 | } |
107 | } |
| 51 | |
108 | |
| 52 | # @FUNCTION: distutils_src_compile |
109 | # @FUNCTION: distutils_src_compile |
| 53 | # @DESCRIPTION: |
110 | # @DESCRIPTION: |
| 54 | # The distutils src_compile function, this function is exported |
111 | # The distutils src_compile function, this function is exported. |
|
|
112 | # In newer EAPIs this function calls distutils_src_compile_pre_hook() and |
|
|
113 | # distutils_src_compile_post_hook(), if they are defined. |
| 55 | distutils_src_compile() { |
114 | distutils_src_compile() { |
| 56 | ${python} setup.py build "$@" || die "compilation failed" |
115 | if [[ "${EBUILD_PHASE}" != "compile" ]]; then |
|
|
116 | die "${FUNCNAME}() can be used only in src_compile() phase" |
|
|
117 | fi |
|
|
118 | |
|
|
119 | if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then |
|
|
120 | if [[ -n "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]]; then |
|
|
121 | building() { |
|
|
122 | _distutils_hook pre |
|
|
123 | |
|
|
124 | echo "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build "$@" |
|
|
125 | "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build "$@" || return "$?" |
|
|
126 | |
|
|
127 | _distutils_hook post |
|
|
128 | } |
|
|
129 | python_execute_function -s building "$@" |
|
|
130 | else |
|
|
131 | building() { |
|
|
132 | _distutils_hook pre |
|
|
133 | |
|
|
134 | echo "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build -b "build-${PYTHON_ABI}" "$@" |
|
|
135 | "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build -b "build-${PYTHON_ABI}" "$@" || return "$?" |
|
|
136 | |
|
|
137 | _distutils_hook post |
|
|
138 | } |
|
|
139 | python_execute_function building "$@" |
|
|
140 | fi |
|
|
141 | else |
|
|
142 | echo "$(PYTHON -A)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build "$@" |
|
|
143 | "$(PYTHON -A)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build "$@" || die "Building failed" |
|
|
144 | fi |
| 57 | } |
145 | } |
| 58 | |
146 | |
| 59 | # @FUNCTION: distutils_src_install |
147 | # @FUNCTION: distutils_src_install |
| 60 | # @DESCRIPTION: |
148 | # @DESCRIPTION: |
| 61 | # The distutils src_install function, this function is exported. |
149 | # The distutils src_install function, this function is exported. |
|
|
150 | # In newer EAPIs this function calls distutils_src_install_pre_hook() and |
|
|
151 | # distutils_src_install_post_hook(), if they are defined. |
| 62 | # It also installs the "standard docs" (CHANGELOG, Change*, KNOWN_BUGS, MAINTAINERS, |
152 | # It also installs the "standard docs" (CHANGELOG, Change*, KNOWN_BUGS, MAINTAINERS, |
| 63 | # PKG-INFO, CONTRIBUTORS, TODO, NEWS, MANIFEST*, README*, and AUTHORS) |
153 | # PKG-INFO, CONTRIBUTORS, TODO, NEWS, MANIFEST*, README*, and AUTHORS) |
| 64 | distutils_src_install() { |
154 | distutils_src_install() { |
|
|
155 | if [[ "${EBUILD_PHASE}" != "install" ]]; then |
|
|
156 | die "${FUNCNAME}() can be used only in src_install() phase" |
|
|
157 | fi |
| 65 | |
158 | |
| 66 | # Mark the package to be rebuilt after a python upgrade. |
159 | local pylibdir |
| 67 | python_need_rebuild |
|
|
| 68 | |
160 | |
|
|
161 | if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then |
|
|
162 | if [[ -z "${DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS}" && "${BASH_VERSINFO[0]}" -ge "4" ]]; then |
|
|
163 | declare -A wrapper_scripts=() |
|
|
164 | |
|
|
165 | rename_scripts_with_versioned_shebangs() { |
|
|
166 | if [[ -d "${D}usr/bin" ]]; then |
|
|
167 | cd "${D}usr/bin" |
|
|
168 | |
|
|
169 | local file |
|
|
170 | for file in *; do |
|
|
171 | if [[ -f "${file}" && ! "${file}" =~ [[:digit:]]+\.[[:digit:]]+$ && "$(head -n1 "${file}")" =~ ^'#!'.*python[[:digit:]]+\.[[:digit:]]+ ]]; then |
|
|
172 | mv "${file}" "${file}-${PYTHON_ABI}" || die "Renaming of '${file}' failed" |
|
|
173 | wrapper_scripts+=(["${D}usr/bin/${file}"]=) |
|
|
174 | fi |
|
|
175 | done |
|
|
176 | fi |
|
|
177 | } |
|
|
178 | fi |
|
|
179 | |
|
|
180 | if [[ -n "${DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES}" ]]; then |
|
|
181 | installation() { |
|
|
182 | _distutils_hook pre |
|
|
183 | |
| 69 | # need this for python-2.5 + setuptools in cases where |
184 | # need this for python-2.5 + setuptools in cases where |
| 70 | # a package uses distutils but does not install anything |
185 | # a package uses distutils but does not install anything |
| 71 | # in site-packages. (eg. dev-java/java-config-2.x) |
186 | # in site-packages. (eg. dev-java/java-config-2.x) |
| 72 | # - liquidx (14/08/2006) |
187 | # - liquidx (14/08/2006) |
| 73 | pylibdir="$(${python} -c 'from distutils.sysconfig import get_python_lib; print get_python_lib()')" |
188 | pylibdir="$("$(PYTHON)" -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')" |
| 74 | [ -n "${pylibdir}" ] && dodir "${pylibdir}" |
189 | [[ -n "${pylibdir}" ]] && dodir "${pylibdir}" |
| 75 | |
190 | |
| 76 | if has_version ">=dev-lang/python-2.3"; then |
191 | echo "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@" |
| 77 | ${python} setup.py install --root="${D}" --no-compile "$@" ||\ |
192 | "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@" || return "$?" |
| 78 | die "python setup.py install failed" |
193 | |
|
|
194 | if [[ -z "${DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS}" && "${BASH_VERSINFO[0]}" -ge "4" ]]; then |
|
|
195 | rename_scripts_with_versioned_shebangs |
|
|
196 | fi |
|
|
197 | |
|
|
198 | _distutils_hook post |
|
|
199 | } |
|
|
200 | python_execute_function -s installation "$@" |
|
|
201 | else |
|
|
202 | installation() { |
|
|
203 | _distutils_hook pre |
|
|
204 | |
|
|
205 | # need this for python-2.5 + setuptools in cases where |
|
|
206 | # a package uses distutils but does not install anything |
|
|
207 | # in site-packages. (eg. dev-java/java-config-2.x) |
|
|
208 | # - liquidx (14/08/2006) |
|
|
209 | pylibdir="$("$(PYTHON)" -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')" |
|
|
210 | [[ -n "${pylibdir}" ]] && dodir "${pylibdir}" |
|
|
211 | |
|
|
212 | echo "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build -b "build-${PYTHON_ABI}" install --root="${D}" --no-compile "$@" |
|
|
213 | "$(PYTHON)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" build -b "build-${PYTHON_ABI}" install --root="${D}" --no-compile "$@" || return "$?" |
|
|
214 | |
|
|
215 | if [[ -z "${DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS}" && "${BASH_VERSINFO[0]}" -ge "4" ]]; then |
|
|
216 | rename_scripts_with_versioned_shebangs |
|
|
217 | fi |
|
|
218 | |
|
|
219 | _distutils_hook post |
|
|
220 | } |
|
|
221 | python_execute_function installation "$@" |
|
|
222 | fi |
|
|
223 | |
|
|
224 | if [[ -z "${DISTUTILS_DISABLE_VERSIONING_OF_PYTHON_SCRIPTS}" && "${#wrapper_scripts[@]}" -ne "0" && "${BASH_VERSINFO[0]}" -ge "4" ]]; then |
|
|
225 | python_generate_wrapper_scripts "${!wrapper_scripts[@]}" |
|
|
226 | fi |
|
|
227 | unset wrapper_scripts |
| 79 | else |
228 | else |
| 80 | ${python} setup.py install --root="${D}" "$@" ||\ |
229 | # Mark the package to be rebuilt after a Python upgrade. |
| 81 | die "python setup.py install failed" |
230 | python_need_rebuild |
| 82 | fi |
|
|
| 83 | |
231 | |
| 84 | DDOCS="CHANGELOG KNOWN_BUGS MAINTAINERS PKG-INFO CONTRIBUTORS TODO NEWS" |
232 | # need this for python-2.5 + setuptools in cases where |
| 85 | DDOCS="${DDOCS} Change* MANIFEST* README* AUTHORS" |
233 | # a package uses distutils but does not install anything |
|
|
234 | # in site-packages. (eg. dev-java/java-config-2.x) |
|
|
235 | # - liquidx (14/08/2006) |
|
|
236 | pylibdir="$("$(PYTHON -A)" -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')" |
|
|
237 | [[ -n "${pylibdir}" ]] && dodir "${pylibdir}" |
| 86 | |
238 | |
| 87 | for doc in ${DDOCS}; do |
239 | echo "$(PYTHON -A)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@" |
|
|
240 | "$(PYTHON -A)" setup.py "${DISTUTILS_GLOBAL_OPTIONS[@]}" install --root="${D}" --no-compile "$@" || die "Installation failed" |
|
|
241 | fi |
|
|
242 | |
|
|
243 | if [[ -e "${D}usr/local" ]]; then |
|
|
244 | die "Illegal installation into /usr/local" |
|
|
245 | fi |
|
|
246 | |
|
|
247 | local default_docs |
|
|
248 | default_docs="AUTHORS Change* CHANGELOG CONTRIBUTORS KNOWN_BUGS MAINTAINERS MANIFEST* NEWS PKG-INFO README* TODO" |
|
|
249 | |
|
|
250 | local doc |
|
|
251 | for doc in ${default_docs}; do |
| 88 | [ -s "$doc" ] && dodoc $doc |
252 | [[ -s "${doc}" ]] && dodoc "${doc}" |
| 89 | done |
253 | done |
| 90 | |
254 | |
| 91 | [ -n "${DOCS}" ] && dodoc ${DOCS} |
255 | if [[ -n "${DOCS}" ]]; then |
|
|
256 | dodoc ${DOCS} || die "dodoc failed" |
|
|
257 | fi |
|
|
258 | } |
|
|
259 | |
|
|
260 | # @FUNCTION: distutils_pkg_postinst |
|
|
261 | # @DESCRIPTION: |
|
|
262 | # This is a generic optimization, you should override it if your package |
|
|
263 | # installs modules in another directory. This function is exported. |
|
|
264 | distutils_pkg_postinst() { |
|
|
265 | if [[ "${EBUILD_PHASE}" != "postinst" ]]; then |
|
|
266 | die "${FUNCNAME}() can be used only in pkg_postinst() phase" |
|
|
267 | fi |
|
|
268 | |
|
|
269 | local pylibdir pymod |
|
|
270 | if [[ -z "${PYTHON_MODNAME}" ]]; then |
|
|
271 | for pylibdir in "${ROOT}"/usr/$(get_libdir)/python*; do |
|
|
272 | if [[ -d "${pylibdir}/site-packages/${PN}" ]]; then |
|
|
273 | PYTHON_MODNAME="${PN}" |
|
|
274 | fi |
|
|
275 | done |
|
|
276 | fi |
|
|
277 | |
|
|
278 | if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then |
|
|
279 | python_mod_optimize ${PYTHON_MODNAME} |
|
|
280 | else |
|
|
281 | for pymod in ${PYTHON_MODNAME}; do |
|
|
282 | python_mod_optimize "$(python_get_sitedir)/${pymod}" |
|
|
283 | done |
|
|
284 | fi |
| 92 | } |
285 | } |
| 93 | |
286 | |
| 94 | # @FUNCTION: distutils_pkg_postrm |
287 | # @FUNCTION: distutils_pkg_postrm |
| 95 | # @DESCRIPTION: |
288 | # @DESCRIPTION: |
| 96 | # Generic pyc/pyo cleanup script. This function is exported. |
289 | # Generic pyc/pyo cleanup script. This function is exported. |
| 97 | distutils_pkg_postrm() { |
290 | distutils_pkg_postrm() { |
|
|
291 | if [[ "${EBUILD_PHASE}" != "postrm" ]]; then |
|
|
292 | die "${FUNCNAME}() can be used only in pkg_postrm() phase" |
|
|
293 | fi |
|
|
294 | |
| 98 | local moddir pylibdir pymod |
295 | local pylibdir pymod |
| 99 | if [[ -z "${PYTHON_MODNAME}" ]]; then |
296 | if [[ -z "${PYTHON_MODNAME}" ]]; then |
| 100 | for pylibdir in "${ROOT}"/usr/$(get_libdir)/python*; do |
297 | for pylibdir in "${ROOT}"/usr/$(get_libdir)/python*; do |
| 101 | if [[ -d "${pylibdir}"/site-packages/${PN} ]]; then |
298 | if [[ -d "${pylibdir}/site-packages/${PN}" ]]; then |
| 102 | PYTHON_MODNAME=${PN} |
299 | PYTHON_MODNAME="${PN}" |
| 103 | fi |
300 | fi |
| 104 | done |
301 | done |
| 105 | fi |
302 | fi |
| 106 | |
303 | |
| 107 | if has_version ">=dev-lang/python-2.3"; then |
|
|
| 108 | ebegin "Performing Python Module Cleanup .." |
|
|
| 109 | if [[ -n "${PYTHON_MODNAME}" ]]; then |
304 | if [[ -n "${PYTHON_MODNAME}" ]]; then |
|
|
305 | if ! has "${EAPI:-0}" 0 1 2 || [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then |
|
|
306 | python_mod_cleanup ${PYTHON_MODNAME} |
|
|
307 | else |
| 110 | for pymod in ${PYTHON_MODNAME}; do |
308 | for pymod in ${PYTHON_MODNAME}; do |
| 111 | for pylibdir in "${ROOT}"/usr/$(get_libdir)/python*; do |
309 | for pylibdir in "${ROOT}"/usr/$(get_libdir)/python*; do |
| 112 | if [[ -d "${pylibdir}"/site-packages/${pymod} ]]; then |
310 | if [[ -d "${pylibdir}/site-packages/${pymod}" ]]; then |
| 113 | python_mod_cleanup "${pylibdir#${ROOT}}"/site-packages/${pymod} |
311 | python_mod_cleanup "${pylibdir#${ROOT}}/site-packages/${pymod}" |
| 114 | fi |
312 | fi |
| 115 | done |
313 | done |
| 116 | done |
314 | done |
|
|
315 | fi |
| 117 | else |
316 | else |
| 118 | python_mod_cleanup |
317 | python_mod_cleanup |
| 119 | fi |
|
|
| 120 | eend 0 |
|
|
| 121 | fi |
|
|
| 122 | } |
|
|
| 123 | |
|
|
| 124 | # @FUNCTION: distutils_pkg_postinst |
|
|
| 125 | # @DESCRIPTION: |
|
|
| 126 | # This is a generic optimization, you should override it if your package |
|
|
| 127 | # installs things in another directory. This function is exported |
|
|
| 128 | distutils_pkg_postinst() { |
|
|
| 129 | local pylibdir pymod |
|
|
| 130 | if [[ -z "${PYTHON_MODNAME}" ]]; then |
|
|
| 131 | for pylibdir in "${ROOT}"/usr/$(get_libdir)/python*; do |
|
|
| 132 | if [[ -d "${pylibdir}"/site-packages/${PN} ]]; then |
|
|
| 133 | PYTHON_MODNAME=${PN} |
|
|
| 134 | fi |
|
|
| 135 | done |
|
|
| 136 | fi |
|
|
| 137 | |
|
|
| 138 | if has_version ">=dev-lang/python-2.3"; then |
|
|
| 139 | python_version |
|
|
| 140 | for pymod in ${PYTHON_MODNAME}; do |
|
|
| 141 | python_mod_optimize \ |
|
|
| 142 | /usr/$(get_libdir)/python${PYVER}/site-packages/${pymod} |
|
|
| 143 | done |
|
|
| 144 | fi |
318 | fi |
| 145 | } |
319 | } |
| 146 | |
320 | |
| 147 | # @FUNCTION: distutils_python_version |
321 | # @FUNCTION: distutils_python_version |
| 148 | # @DESCRIPTION: |
322 | # @DESCRIPTION: |
| 149 | # Calls python_version, so that you can use something like |
323 | # Calls python_version, so that you can use something like |
| 150 | # e.g. insinto ${ROOT}/usr/include/python${PYVER} |
324 | # e.g. insinto $(python_get_includedir) |
| 151 | distutils_python_version() { |
325 | distutils_python_version() { |
|
|
326 | if ! has "${EAPI:-0}" 0 1 2; then |
|
|
327 | die "${FUNCNAME}() cannot be used in this EAPI" |
|
|
328 | fi |
|
|
329 | |
| 152 | python_version |
330 | python_version |
| 153 | } |
331 | } |
| 154 | |
332 | |
| 155 | # @FUNCTION: distutils_python_tkinter |
333 | # @FUNCTION: distutils_python_tkinter |
| 156 | # @DESCRIPTION: |
334 | # @DESCRIPTION: |
| 157 | # Checks for if tkinter support is compiled into python |
335 | # Checks for if tkinter support is compiled into python |
| 158 | distutils_python_tkinter() { |
336 | distutils_python_tkinter() { |
|
|
337 | if ! has "${EAPI:-0}" 0 1 2; then |
|
|
338 | die "${FUNCNAME}() cannot be used in this EAPI" |
|
|
339 | fi |
|
|
340 | |
| 159 | python_tkinter_exists |
341 | python_tkinter_exists |
| 160 | } |
342 | } |
| 161 | |
|
|
| 162 | EXPORT_FUNCTIONS src_unpack src_compile src_install pkg_postinst pkg_postrm |
|
|