Gentoo Archives: gentoo-commits

From: "Tiziano Mueller (dev-zero)" <dev-zero@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in eclass: distutils.eclass python.eclass
Date: Thu, 28 Feb 2008 20:20:36
Message-Id: E1JUpF2-0006Ny-Qh@stork.gentoo.org
1 dev-zero 08/02/28 20:20:32
2
3 Modified: distutils.eclass python.eclass
4 Log:
5 Committed patches from bugs #210362 and #209671 to make the distutils and python eclasses ready for eclass-manpage.
6
7 Revision Changes Path
8 1.46 eclass/distutils.eclass
9
10 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/distutils.eclass?rev=1.46&view=markup
11 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/distutils.eclass?rev=1.46&content-type=text/plain
12 diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/distutils.eclass?r1=1.45&r2=1.46
13
14 Index: distutils.eclass
15 ===================================================================
16 RCS file: /var/cvsroot/gentoo-x86/eclass/distutils.eclass,v
17 retrieving revision 1.45
18 retrieving revision 1.46
19 diff -u -r1.45 -r1.46
20 --- distutils.eclass 23 Jan 2008 22:19:04 -0000 1.45
21 +++ distutils.eclass 28 Feb 2008 20:20:32 -0000 1.46
22 @@ -1,26 +1,24 @@
23 -# Copyright 1999-2004 Gentoo Foundation
24 +# Copyright 1999-2008 Gentoo Foundation
25 # Distributed under the terms of the GNU General Public License v2
26 -# $Header: /var/cvsroot/gentoo-x86/eclass/distutils.eclass,v 1.45 2008/01/23 22:19:04 hawking Exp $
27 -#
28 -# Author: Jon Nelson <jnelson@g.o>
29 -# Current Maintainer: Alastair Tse <liquidx@g.o>
30 +# $Header: /var/cvsroot/gentoo-x86/eclass/distutils.eclass,v 1.46 2008/02/28 20:20:32 dev-zero Exp $
31 +
32 +# @ECLASS: distutils.eclass
33 +# @MAINTAINER:
34 +# Alastair Tse <liquidx@g.o>
35 #
36 +# Original author: Jon Nelson <jnelson@g.o>
37 +# @BLURB: This eclass allows easier installation of distutils-based python modules
38 +# @DESCRIPTION:
39 # The distutils eclass is designed to allow easier installation of
40 # distutils-based python modules and their incorporation into
41 # the Gentoo Linux system.
42 #
43 -# - Features:
44 -# distutils_src_compile() - does python setup.py build
45 -# distutils_src_install() - does python setup.py install and install docs
46 -# distutils_python_version() - sets PYVER/PYVER_MAJOR/PYVER_MINOR
47 -# distutils_python_tkinter() - checks for tkinter support in python
48 -#
49 -# - Variables:
50 -# PYTHON_SLOT_VERSION - for Zope support
51 -# DOCS - additional DOCS
52 +# It inherits python, multilib, and eutils
53
54 inherit python multilib eutils
55
56 +# @ECLASS-VARIABLE: PYTHON_SLOT_VERSION
57 +# @DESCRIPTION:
58 # This helps make it possible to add extensions to python slots.
59 # Normally only a -py21- ebuild would set PYTHON_SLOT_VERSION.
60 if [ "${PYTHON_SLOT_VERSION}" = "2.1" ] ; then
61 @@ -34,6 +32,13 @@
62 python="python"
63 fi
64
65 +# @ECLASS-VARIABLE: DOCS
66 +# @DESCRIPTION:
67 +# Additional DOCS
68 +
69 +# @FUNCTION: distutils_src_unpack
70 +# @DESCRIPTION:
71 +# The distutils src_unpack function, this function is exported
72 distutils_src_unpack() {
73 unpack ${A}
74 cd "${S}"
75 @@ -44,10 +49,18 @@
76 echo "def use_setuptools(*args, **kwargs): pass" > ez_setup.py
77 }
78
79 +# @FUNCTION: distutils_src_compile
80 +# @DESCRIPTION:
81 +# The distutils src_compile function, this function is exported
82 distutils_src_compile() {
83 ${python} setup.py build "$@" || die "compilation failed"
84 }
85
86 +# @FUNCTION: distutils_src_install
87 +# @DESCRIPTION:
88 +# The distutils src_install function, this function is exported.
89 +# It also installs the "standard docs" (CHANGELOG, Change*, KNOWN_BUGS, MAINTAINERS,
90 +# PKG-INFO, CONTRIBUTORS, TODO, NEWS, MANIFEST*, README*, and AUTHORS)
91 distutils_src_install() {
92
93 # need this for python-2.5 + setuptools in cases where
94 @@ -73,8 +86,9 @@
95 [ -n "${DOCS}" ] && dodoc ${DOCS}
96 }
97
98 -# generic pyc/pyo cleanup script.
99 -
100 +# @FUNCTION: distutils_pkg_postrm
101 +# @DESCRIPTION:
102 +# Generic pyc/pyo cleanup script. This function is exported.
103 distutils_pkg_postrm() {
104 PYTHON_MODNAME=${PYTHON_MODNAME:-${PN}}
105
106 @@ -93,9 +107,10 @@
107 fi
108 }
109
110 -# this is a generic optimization, you should override it if your package
111 -# installs things in another directory
112 -
113 +# @FUNCTION: distutils_pkg_postinst
114 +# @DESCRIPTION:
115 +# This is a generic optimization, you should override it if your package
116 +# installs things in another directory. This function is exported
117 distutils_pkg_postinst() {
118 PYTHON_MODNAME=${PYTHON_MODNAME:-${PN}}
119
120 @@ -112,13 +127,17 @@
121 fi
122 }
123
124 -# e.g. insinto ${ROOT}/usr/include/python${PYVER}
125 -
126 +# @FUNCTION: distutils_python_version
127 +# @DESCRIPTION:
128 +# Calls python_version, so that you can use something like
129 +# e.g. insinto ${ROOT}/usr/include/python${PYVER}
130 distutils_python_version() {
131 python_version
132 }
133
134 -# checks for if tkinter support is compiled into python
135 +# @FUNCTION: distutils_python_tkinter
136 +# @DESCRIPTION:
137 +# Checks for if tkinter support is compiled into python
138 distutils_python_tkinter() {
139 python_tkinter_exists
140 }
141
142
143
144 1.33 eclass/python.eclass
145
146 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.33&view=markup
147 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?rev=1.33&content-type=text/plain
148 diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/python.eclass?r1=1.32&r2=1.33
149
150 Index: python.eclass
151 ===================================================================
152 RCS file: /var/cvsroot/gentoo-x86/eclass/python.eclass,v
153 retrieving revision 1.32
154 retrieving revision 1.33
155 diff -u -r1.32 -r1.33
156 --- python.eclass 6 May 2007 22:11:12 -0000 1.32
157 +++ python.eclass 28 Feb 2008 20:20:32 -0000 1.33
158 @@ -1,22 +1,15 @@
159 -# Copyright 1999-2004 Gentoo Foundation
160 +# Copyright 1999-2008 Gentoo Foundation
161 # Distributed under the terms of the GNU General Public License v2
162 -# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.32 2007/05/06 22:11:12 kloeri Exp $
163 -#
164 -# Author: Alastair Tse <liquidx@g.o>
165 -#
166 -# A Utility Eclass that should be inherited by anything that deals with
167 -# Python or Python modules.
168 -#
169 -# - Features:
170 -# python_version() - sets PYVER/PYVER_MAJOR/PYVER_MINOR
171 -# python_tkinter_exists() - Checks for tkinter support in python
172 -# python_mod_exists() - Checks if a python module exists
173 -# python_mod_compile() - Compiles a .py file to a .pyc/.pyo
174 -# python_mod_optimize() - Generates .pyc/.pyo precompiled scripts
175 -# python_mod_cleanup() - Goes through /usr/lib*/python* to remove
176 -# orphaned *.pyc *.pyo
177 -# python_makesym() - Makes /usr/bin/python symlinks
178 +# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.33 2008/02/28 20:20:32 dev-zero Exp $
179
180 +# @ECLASS: python.eclass
181 +# @MAINTAINER:
182 +# python@g.o
183 +#
184 +# original author: Alastair Tse <liquidx@g.o>
185 +# @BLURB: A Utility Eclass that should be inherited by anything that deals with Python or Python modules.
186 +# @DESCRIPTION:
187 +# Some useful functions for dealing with python.
188 inherit alternatives multilib
189
190
191 @@ -43,11 +36,11 @@
192 echo " PYVER_MINOR: $PYVER_MINOR PYVER_MICRO: $PYVER_MICRO"
193 }
194
195 -#
196 -# name: python_disable/enable_pyc
197 -# desc: tells python not to automatically recompile modules to .pyc/.pyo
198 -# even if the timestamps/version stamps don't match. this is
199 -# done to protect sandbox.
200 +# @FUNCTION: python_disable_pyc
201 +# @DESCRIPTION:
202 +# Tells python not to automatically recompile modules to .pyc/.pyo
203 +# even if the timestamps/version stamps don't match. This is done
204 +# to protect sandbox.
205 #
206 # note: supported by >=dev-lang/python-2.2.3-r3 only.
207 #
208 @@ -55,18 +48,20 @@
209 export PYTHON_DONTCOMPILE=1
210 }
211
212 +# @FUNCTION: python_enable_pyc
213 +# @DESCRIPTION:
214 +# Tells python to automatically recompile modules to .pyc/.pyo if the
215 +# timestamps/version stamps change
216 python_enable_pyc() {
217 unset PYTHON_DONTCOMPILE
218 }
219
220 python_disable_pyc
221
222 -#
223 -# name: python_version
224 -# desc: run without arguments and it will export the version of python
225 -# currently in use as $PYVER
226 -#
227 -
228 +# @FUNCTION: python_version
229 +# @DESCRIPTION:
230 +# Run without arguments and it will export the version of python
231 +# currently in use as $PYVER; sets PYVER/PYVER_MAJOR/PYVER_MINOR
232 __python_version_extract() {
233 verstr=$1
234 export PYVER_MAJOR=${verstr:0:1}
235 @@ -85,21 +80,19 @@
236 __python_version_extract $PYVER_ALL
237 }
238
239 -#
240 -# name: python_makesym
241 -# desc: run without arguments, it will create the /usr/bin/python symlinks
242 -# to the latest installed version
243 -#
244 +# @FUNCTION: python_makesym
245 +# @DESCRIPTION:
246 +# Run without arguments, it will create the /usr/bin/python symlinks
247 +# to the latest installed version
248 python_makesym() {
249 alternatives_auto_makesym "/usr/bin/python" "python[0-9].[0-9]"
250 alternatives_auto_makesym "/usr/bin/python2" "python2.[0-9]"
251 }
252
253 -#
254 -# name: python_tkinter_exists
255 -# desc: run without arguments, checks if python was compiled with Tkinter
256 -# support. If not, prints an error message and dies.
257 -#
258 +# @FUNCTION: python_tkinter_exists
259 +# @DESCRIPTION:
260 +# Run without arguments, checks if python was compiled with Tkinter
261 +# support. If not, prints an error message and dies.
262 python_tkinter_exists() {
263 if ! python -c "import Tkinter" >/dev/null 2>&1; then
264 eerror "You need to recompile python with Tkinter support."
265 @@ -110,17 +103,18 @@
266 fi
267 }
268
269 +# @FUNCTION: python_mod_exists
270 +# @USAGE: < module >
271 +# @DESCRIPTION:
272 +# Run with the module name as an argument. it will check if a
273 +# python module is installed and loadable. it will return
274 +# TRUE(0) if the module exists, and FALSE(1) if the module does
275 +# not exist.
276 #
277 -# name: python_mod_exists
278 -# desc: run with the module name as an argument. it will check if a
279 -# python module is installed and loadable. it will return
280 -# TRUE(0) if the module exists, and FALSE(1) if the module does
281 -# not exist.
282 -# exam:
283 +# Example:
284 # if python_mod_exists gtk; then
285 # echo "gtk support enabled"
286 # fi
287 -#
288 python_mod_exists() {
289 [ -z "$1" ] && die "${FUNCTION} requires an argument!"
290 if ! python -c "import $1" >/dev/null 2>&1; then
291 @@ -129,11 +123,13 @@
292 return 0
293 }
294
295 +# @FUNCTION: python_mod_compile
296 +# @USAGE: < file >
297 +# @DESCRIPTION:
298 +# Given a filename, it will pre-compile the module's .pyc and .pyo.
299 +# should only be run in pkg_postinst()
300 #
301 -# name: python_mod_compile
302 -# desc: given a filename, it will pre-compile the module's .pyc and .pyo.
303 -# should only be run in pkg_postinst()
304 -# exam:
305 +# Example:
306 # python_mod_compile ${ROOT}usr/lib/python2.3/site-packages/pygoogle.py
307 #
308 python_mod_compile() {
309 @@ -154,17 +150,18 @@
310 fi
311 }
312
313 +# @FUNCTION: python_mod_optimize
314 +# @USAGE: [ path ]
315 +# @DESCRIPTION:
316 +# If no arguments supplied, it will recompile all modules under
317 +# sys.path (eg. /usr/lib/python2.3, /usr/lib/python2.3/site-packages/ ..)
318 +# no recursively
319 #
320 -# name: python_mod_optimize
321 -# desc: if no arguments supplied, it will recompile all modules under
322 -# sys.path (eg. /usr/lib/python2.3, /usr/lib/python2.3/site-packages/ ..)
323 -# no recursively
324 -#
325 -# if supplied with arguments, it will recompile all modules recursively
326 -# in the supplied directory
327 -# exam:
328 -# python_mod_optimize ${ROOT}usr/share/codegen
329 +# If supplied with arguments, it will recompile all modules recursively
330 +# in the supplied directory
331 #
332 +# Example:
333 +# python_mod_optimize ${ROOT}usr/share/codegen
334 python_mod_optimize() {
335 local myroot
336 # strip trailing slash
337 @@ -190,15 +187,15 @@
338 eend $?
339 }
340
341 -#
342 -# name: python_mod_cleanup
343 -# desc: run with optional arguments, where arguments are directories of
344 -# python modules. if none given, it will look in /usr/lib/python[0-9].[0-9]
345 -#
346 -# it will recursively scan all compiled python modules in the directories
347 -# and determine if they are orphaned (eg. their corresponding .py is missing.)
348 -# if they are, then it will remove their corresponding .pyc and .pyo
349 -#
350 +# @FUNCTION: python_mod_cleanup
351 +# @USAGE: [ dir ]
352 +# @DESCRIPTION:
353 +# Run with optional arguments, where arguments are directories of
354 +# python modules. if none given, it will look in /usr/lib/python[0-9].[0-9]
355 +#
356 +# It will recursively scan all compiled python modules in the directories
357 +# and determine if they are orphaned (eg. their corresponding .py is missing.)
358 +# if they are, then it will remove their corresponding .pyc and .pyo
359 python_mod_cleanup() {
360 local SEARCH_PATH myroot
361
362
363
364
365 --
366 gentoo-commits@l.g.o mailing list