Gentoo Archives: gentoo-python

From: "Michał Górny" <mgorny@g.o>
To: gentoo-python@l.g.o
Cc: python@g.o, "Michał Górny" <mgorny@g.o>
Subject: [gentoo-python] [PATCH python-ebuilds] python2.7: first ebuild converted to python-utils-r1.
Date: Wed, 21 Nov 2012 20:35:16
Message-Id: 1353530178-2569-1-git-send-email-mgorny@gentoo.org
1 Please review these changes. I will send a detailed note about
2 the particular changes I've made in a reply to this mail.
3
4 The general changes are:
5
6 - clean up, update, getting rid of python.eclass implicity,
7
8 - the compiled modules are now part of the package (as with other
9 python-r1 suite ebuilds),
10
11 - an additional 'epython' module is installed which could be used to
12 quickly get the correct 'EPYTHON' value for the current Python
13 implementation (it will be used in python-exec's .py support).
14 ---
15 ...thon-2.7.3-r2.ebuild => python-2.7.3-r3.ebuild} | 110 +++++++++------------
16 1 file changed, 49 insertions(+), 61 deletions(-)
17 copy gx86/dev-lang/python/{python-2.7.3-r2.ebuild => python-2.7.3-r3.ebuild} (68%)
18
19 diff --git a/gx86/dev-lang/python/python-2.7.3-r2.ebuild b/gx86/dev-lang/python/python-2.7.3-r3.ebuild
20 similarity index 68%
21 copy from gx86/dev-lang/python/python-2.7.3-r2.ebuild
22 copy to gx86/dev-lang/python/python-2.7.3-r3.ebuild
23 index e9112a4..0368c65 100644
24 --- a/gx86/dev-lang/python/python-2.7.3-r2.ebuild
25 +++ b/gx86/dev-lang/python/python-2.7.3-r3.ebuild
26 @@ -2,11 +2,11 @@
27 # Distributed under the terms of the GNU General Public License v2
28 # $Header: /var/cvsroot/gentoo-x86/dev-lang/python/python-2.7.3-r2.ebuild,v 1.12 2012/07/30 18:09:26 vapier Exp $
29
30 -EAPI="2"
31 +EAPI=4
32 WANT_AUTOMAKE="none"
33 WANT_LIBTOOL="none"
34
35 -inherit autotools eutils flag-o-matic multilib pax-utils python toolchain-funcs
36 +inherit autotools eutils flag-o-matic multilib pax-utils python-utils-r1 toolchain-funcs
37
38 MY_P="Python-${PV}"
39 PATCHSET_REVISION="1"
40 @@ -18,11 +18,11 @@ SRC_URI="http://www.python.org/ftp/python/${PV}/${MY_P}.tar.bz2
41
42 LICENSE="PSF-2"
43 SLOT="2.7"
44 -PYTHON_ABI="${SLOT}"
45 -KEYWORDS="alpha amd64 arm hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
46 +KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
47 IUSE="-berkdb build doc elibc_uclibc examples gdbm ipv6 +ncurses +readline sqlite +ssl +threads tk +wide-unicode wininst +xml"
48
49 RDEPEND="app-arch/bzip2
50 + app-admin/eselect-python
51 >=sys-libs/zlib-1.1.3
52 virtual/libffi
53 virtual/libintl
54 @@ -56,20 +56,20 @@ DEPEND="${RDEPEND}
55 !sys-devel/gcc[libffi]"
56 RDEPEND+=" !build? ( app-misc/mime-types )
57 doc? ( dev-python/python-docs:${SLOT} )"
58 +PDEPEND="app-admin/python-updater"
59
60 S="${WORKDIR}/${MY_P}"
61
62 pkg_setup() {
63 - python_pkg_setup
64 -
65 if use berkdb; then
66 - ewarn "\"bsddb\" module is out-of-date and no longer maintained inside dev-lang/python."
67 - ewarn "\"bsddb\" and \"dbhash\" modules have been additionally removed in Python 3."
68 - ewarn "You should use external, still maintained \"bsddb3\" module provided by dev-python/bsddb3,"
69 - ewarn "which supports both Python 2 and Python 3."
70 + ewarn "'bsddb' module is out-of-date and no longer maintained inside"
71 + ewarn "dev-lang/python. 'bsddb' and 'dbhash' modules have been additionally"
72 + ewarn "removed in Python 3. A maintained alternative of 'bsddb3' module"
73 + ewarn "is provided by dev-python/bsddb3."
74 else
75 if has_version "=${CATEGORY}/${PN}-${PV%%.*}*[berkdb]"; then
76 - ewarn "You are migrating from =${CATEGORY}/${PN}-${PV%%.*}*[berkdb] to =${CATEGORY}/${PN}-${PV%%.*}*[-berkdb]."
77 + ewarn "You are migrating from =${CATEGORY}/${PN}-${PV%%.*}*[berkdb]"
78 + ewarn "to =${CATEGORY}/${PN}-${PV%%.*}*[-berkdb]."
79 ewarn "You might need to migrate your databases."
80 fi
81 fi
82 @@ -152,7 +152,7 @@ src_configure() {
83 if tc-is-cross-compiler; then
84 OPT="-O1" CFLAGS="" LDFLAGS="" CC="" \
85 ./configure --{build,host}=${CBUILD} || die "cross-configure failed"
86 - emake python Parser/pgen || die "cross-make failed"
87 + emake python Parser/pgen
88 mv python hostpython
89 mv Parser/pgen Parser/hostpgen
90 make distclean
91 @@ -197,7 +197,7 @@ src_configure() {
92 }
93
94 src_compile() {
95 - emake EPYTHON="python${PV%%.*}" || die "emake failed"
96 + default
97
98 # Work around bug 329499. See also bug 413751.
99 pax-mark m python
100 @@ -210,23 +210,18 @@ src_test() {
101 return
102 fi
103
104 - # Byte compiling should be enabled here.
105 - # Otherwise test_import fails.
106 - python_enable_pyc
107 -
108 # Skip failing tests.
109 local skipped_tests="distutils gdb"
110
111 for test in ${skipped_tests}; do
112 - mv Lib/test/test_${test}.py "${T}"
113 + mv Lib/test/test_${test}.py "${T}" || die
114 done
115
116 # Rerun failed tests in verbose mode (regrtest -w).
117 emake test EXTRATESTOPTS="-w" < /dev/tty
118 - local result="$?"
119
120 for test in ${skipped_tests}; do
121 - mv "${T}/test_${test}.py" Lib/test
122 + mv "${T}/test_${test}.py" Lib/test || die
123 done
124
125 elog "The following tests have been skipped:"
126 @@ -235,73 +230,69 @@ src_test() {
127 done
128
129 elog "If you would like to run them, you may:"
130 - elog "cd '${EPREFIX}$(python_get_libdir)/test'"
131 + elog "cd '${EPREFIX}/usr/$(get_libdir)/python${SLOT}/test'"
132 elog "and run the tests separately."
133 -
134 - python_disable_pyc
135 -
136 - if [[ "${result}" -ne 0 ]]; then
137 - die "emake test failed"
138 - fi
139 }
140
141 src_install() {
142 - [[ -z "${ED}" ]] && ED="${D%/}${EPREFIX}/"
143 + local libdir=${ED}/usr/$(get_libdir)/python${SLOT}
144
145 - emake DESTDIR="${D}" altinstall maninstall || die "emake altinstall maninstall failed"
146 - python_clean_installation_image -q
147 + emake DESTDIR="${D}" altinstall maninstall
148
149 - sed -e "s/\(LDFLAGS=\).*/\1/" -i "${ED}$(python_get_libdir)/config/Makefile" || die "sed failed"
150 + sed -e "s/\(LDFLAGS=\).*/\1/" \
151 + -i "${libdir}/config/Makefile" || die "sed failed"
152
153 - mv "${ED}usr/bin/python${SLOT}-config" "${ED}usr/bin/python-config-${SLOT}"
154 + mv "${ED}usr/bin/python${SLOT}-config" \
155 + "${ED}usr/bin/python-config-${SLOT}" || die
156
157 # Fix collisions between different slots of Python.
158 - mv "${ED}usr/bin/2to3" "${ED}usr/bin/2to3-${SLOT}"
159 - mv "${ED}usr/bin/pydoc" "${ED}usr/bin/pydoc${SLOT}"
160 - mv "${ED}usr/bin/idle" "${ED}usr/bin/idle${SLOT}"
161 + mv "${ED}usr/bin/2to3" "${ED}usr/bin/2to3-${SLOT}" || die
162 + mv "${ED}usr/bin/pydoc" "${ED}usr/bin/pydoc${SLOT}" || die
163 + mv "${ED}usr/bin/idle" "${ED}usr/bin/idle${SLOT}" || die
164 rm -f "${ED}usr/bin/smtpd.py"
165
166 if use build; then
167 - rm -fr "${ED}usr/bin/idle${SLOT}" "${ED}$(python_get_libdir)/"{bsddb,dbhash.py,idlelib,lib-tk,sqlite3,test}
168 + rm -fr "${ED}usr/bin/idle${SLOT}" "${libdir}/"{bsddb,dbhash.py,idlelib,lib-tk,sqlite3,test}
169 else
170 - use elibc_uclibc && rm -fr "${ED}$(python_get_libdir)/"{bsddb/test,test}
171 - use berkdb || rm -fr "${ED}$(python_get_libdir)/"{bsddb,dbhash.py,test/test_bsddb*}
172 - use sqlite || rm -fr "${ED}$(python_get_libdir)/"{sqlite3,test/test_sqlite*}
173 - use tk || rm -fr "${ED}usr/bin/idle${SLOT}" "${ED}$(python_get_libdir)/"{idlelib,lib-tk}
174 + use elibc_uclibc && rm -fr "${libdir}/"{bsddb/test,test}
175 + use berkdb || rm -fr "${libdir}/"{bsddb,dbhash.py,test/test_bsddb*}
176 + use sqlite || rm -fr "${libdir}/"{sqlite3,test/test_sqlite*}
177 + use tk || rm -fr "${ED}usr/bin/idle${SLOT}" "${libdir}/"{idlelib,lib-tk}
178 fi
179
180 - use threads || rm -fr "${ED}$(python_get_libdir)/multiprocessing"
181 - use wininst || rm -f "${ED}$(python_get_libdir)/distutils/command/"wininst-*.exe
182 + use threads || rm -fr "${libdir}/multiprocessing"
183 + use wininst || rm -f "${libdir}/distutils/command/"wininst-*.exe
184
185 - dodoc Misc/{ACKS,HISTORY,NEWS} || die "dodoc failed"
186 + dodoc Misc/{ACKS,HISTORY,NEWS}
187
188 if use examples; then
189 insinto /usr/share/doc/${PF}/examples
190 - doins -r Tools || die "doins failed"
191 + doins -r Tools
192 fi
193
194 - newconfd "${FILESDIR}/pydoc.conf" pydoc-${SLOT} || die "newconfd failed"
195 - newinitd "${FILESDIR}/pydoc.init" pydoc-${SLOT} || die "newinitd failed"
196 + newconfd "${FILESDIR}/pydoc.conf" pydoc-${SLOT}
197 + newinitd "${FILESDIR}/pydoc.init" pydoc-${SLOT}
198 sed \
199 -e "s:@PYDOC_PORT_VARIABLE@:PYDOC${SLOT/./_}_PORT:" \
200 -e "s:@PYDOC@:pydoc${SLOT}:" \
201 - -i "${ED}etc/conf.d/pydoc-${SLOT}" "${ED}etc/init.d/pydoc-${SLOT}" || die "sed failed"
202 -}
203 + -i "${ED}etc/conf.d/pydoc-${SLOT}" "${ED}etc/init.d/pydoc-${SLOT}" \
204 + || die "pydoc initscript sed failed"
205
206 -pkg_preinst() {
207 - if has_version "<${CATEGORY}/${PN}-${SLOT}" && ! has_version "${CATEGORY}/${PN}:2.7"; then
208 - python_updater_warning="1"
209 - fi
210 + # for python-exec
211 + local EPYTHON=python${SLOT}
212 + echo "EPYTHON='${EPYTHON}'" > epython.py
213 + python_domodule epython.py
214 }
215
216 eselect_python_update() {
217 - [[ -z "${EROOT}" || (! -d "${EROOT}" && -d "${ROOT}") ]] && EROOT="${ROOT%/}${EPREFIX}/"
218 -
219 - if [[ -z "$(eselect python show)" || ! -f "${EROOT}usr/bin/$(eselect python show)" ]]; then
220 + if [[ -z "$(eselect python show)"
221 + || ! -f "${EROOT}usr/bin/$(eselect python show)" ]]; then
222 eselect python update
223 fi
224
225 - if [[ -z "$(eselect python show --python${PV%%.*})" || ! -f "${EROOT}usr/bin/$(eselect python show --python${PV%%.*})" ]]; then
226 + if [[ -z "$(eselect python show --python${PV%%.*})"
227 + || ! -f "${EROOT}usr/bin/$(eselect python show --python${PV%%.*})" ]]
228 + then
229 eselect python update --python${PV%%.*}
230 fi
231 }
232 @@ -309,9 +300,8 @@ eselect_python_update() {
233 pkg_postinst() {
234 eselect_python_update
235
236 - python_mod_optimize -f -x "/(site-packages|test|tests)/" $(python_get_libdir)
237 -
238 - if [[ "${python_updater_warning}" == "1" ]]; then
239 + if has_version "<${CATEGORY}/${PN}-${SLOT}" && [[ ! ${REPLACING_VERSIONS} ]]
240 + then
241 ewarn "You have just upgraded from an older version of Python."
242 ewarn "You should switch active version of Python ${PV%%.*} and run"
243 ewarn "'python-updater [options]' to rebuild Python modules."
244 @@ -320,6 +310,4 @@ pkg_postinst() {
245
246 pkg_postrm() {
247 eselect_python_update
248 -
249 - python_mod_cleanup $(python_get_libdir)
250 }
251 --
252 1.8.0

Replies