/[gentoo-x86]/dev-lang/python/python-2.7.3-r2.ebuild
Gentoo

Contents of /dev-lang/python/python-2.7.3-r2.ebuild

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.12 - (show annotations) (download)
Mon Jul 30 18:09:26 2012 UTC (2 years, 4 months ago) by vapier
Branch: MAIN
Changes since 1.11: +4 -1 lines
Make sure $PKG_CONFIG is respected.

(Portage version: 2.2.0_alpha116/cvs/Linux x86_64)

1 # Copyright 1999-2012 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/dev-lang/python/python-2.7.3-r2.ebuild,v 1.11 2012/07/29 18:34:26 armin76 Exp $
4
5 EAPI="2"
6 WANT_AUTOMAKE="none"
7 WANT_LIBTOOL="none"
8
9 inherit autotools eutils flag-o-matic multilib pax-utils python toolchain-funcs
10
11 MY_P="Python-${PV}"
12 PATCHSET_REVISION="1"
13
14 DESCRIPTION="Python is an interpreted, interactive, object-oriented programming language."
15 HOMEPAGE="http://www.python.org/"
16 SRC_URI="http://www.python.org/ftp/python/${PV}/${MY_P}.tar.bz2
17 mirror://gentoo/python-gentoo-patches-${PV}-${PATCHSET_REVISION}.tar.bz2"
18
19 LICENSE="PSF-2"
20 SLOT="2.7"
21 PYTHON_ABI="${SLOT}"
22 KEYWORDS="alpha amd64 arm hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
23 IUSE="-berkdb build doc elibc_uclibc examples gdbm ipv6 +ncurses +readline sqlite +ssl +threads tk +wide-unicode wininst +xml"
24
25 RDEPEND="app-arch/bzip2
26 >=sys-libs/zlib-1.1.3
27 virtual/libffi
28 virtual/libintl
29 !build? (
30 berkdb? ( || (
31 sys-libs/db:4.8
32 sys-libs/db:4.7
33 sys-libs/db:4.6
34 sys-libs/db:4.5
35 sys-libs/db:4.4
36 sys-libs/db:4.3
37 sys-libs/db:4.2
38 ) )
39 gdbm? ( sys-libs/gdbm[berkdb] )
40 ncurses? (
41 >=sys-libs/ncurses-5.2
42 readline? ( >=sys-libs/readline-4.1 )
43 )
44 sqlite? ( >=dev-db/sqlite-3.3.8:3[extensions] )
45 ssl? ( dev-libs/openssl )
46 tk? (
47 >=dev-lang/tk-8.0
48 dev-tcltk/blt
49 )
50 xml? ( >=dev-libs/expat-2.1 )
51 )
52 !!<sys-apps/portage-2.1.9"
53 DEPEND="${RDEPEND}
54 virtual/pkgconfig
55 >=sys-devel/autoconf-2.65
56 !sys-devel/gcc[libffi]"
57 RDEPEND+=" !build? ( app-misc/mime-types )
58 doc? ( dev-python/python-docs:${SLOT} )"
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 else
71 if has_version "=${CATEGORY}/${PN}-${PV%%.*}*[berkdb]"; then
72 ewarn "You are migrating from =${CATEGORY}/${PN}-${PV%%.*}*[berkdb] to =${CATEGORY}/${PN}-${PV%%.*}*[-berkdb]."
73 ewarn "You might need to migrate your databases."
74 fi
75 fi
76 }
77
78 src_prepare() {
79 # Ensure that internal copies of expat, libffi and zlib are not used.
80 rm -fr Modules/expat
81 rm -fr Modules/_ctypes/libffi*
82 rm -fr Modules/zlib
83
84 local excluded_patches
85 if ! tc-is-cross-compiler; then
86 excluded_patches="*_all_crosscompile.patch"
87 fi
88
89 EPATCH_EXCLUDE="${excluded_patches}" EPATCH_SUFFIX="patch" \
90 epatch "${WORKDIR}/${PV}-${PATCHSET_REVISION}"
91
92 sed -i -e "s:@@GENTOO_LIBDIR@@:$(get_libdir):g" \
93 Lib/distutils/command/install.py \
94 Lib/distutils/sysconfig.py \
95 Lib/site.py \
96 Lib/sysconfig.py \
97 Lib/test/test_site.py \
98 Makefile.pre.in \
99 Modules/Setup.dist \
100 Modules/getpath.c \
101 setup.py || die "sed failed to replace @@GENTOO_LIBDIR@@"
102
103 eautoconf
104 eautoheader
105 }
106
107 src_configure() {
108 if use build; then
109 # Disable extraneous modules with extra dependencies.
110 export PYTHON_DISABLE_MODULES="dbm _bsddb gdbm _curses _curses_panel readline _sqlite3 _tkinter _elementtree pyexpat"
111 export PYTHON_DISABLE_SSL="1"
112 else
113 # dbm module can be linked against berkdb or gdbm.
114 # Defaults to gdbm when both are enabled, #204343.
115 local disable
116 use berkdb || use gdbm || disable+=" dbm"
117 use berkdb || disable+=" _bsddb"
118 use gdbm || disable+=" gdbm"
119 use ncurses || disable+=" _curses _curses_panel"
120 use readline || disable+=" readline"
121 use sqlite || disable+=" _sqlite3"
122 use ssl || export PYTHON_DISABLE_SSL="1"
123 use tk || disable+=" _tkinter"
124 use xml || disable+=" _elementtree pyexpat" # _elementtree uses pyexpat.
125 export PYTHON_DISABLE_MODULES="${disable}"
126
127 if ! use xml; then
128 ewarn "You have configured Python without XML support."
129 ewarn "This is NOT a recommended configuration as you"
130 ewarn "may face problems parsing any XML documents."
131 fi
132 fi
133
134 if [[ -n "${PYTHON_DISABLE_MODULES}" ]]; then
135 einfo "Disabled modules: ${PYTHON_DISABLE_MODULES}"
136 fi
137
138 if [[ "$(gcc-major-version)" -ge 4 ]]; then
139 append-flags -fwrapv
140 fi
141
142 filter-flags -malign-double
143
144 [[ "${ARCH}" == "alpha" ]] && append-flags -fPIC
145
146 # https://bugs.gentoo.org/show_bug.cgi?id=50309
147 if is-flagq -O3; then
148 is-flagq -fstack-protector-all && replace-flags -O3 -O2
149 use hardened && replace-flags -O3 -O2
150 fi
151
152 if tc-is-cross-compiler; then
153 OPT="-O1" CFLAGS="" LDFLAGS="" CC="" \
154 ./configure --{build,host}=${CBUILD} || die "cross-configure failed"
155 emake python Parser/pgen || die "cross-make failed"
156 mv python hostpython
157 mv Parser/pgen Parser/hostpgen
158 make distclean
159 sed -i \
160 -e "/^HOSTPYTHON/s:=.*:=./hostpython:" \
161 -e "/^HOSTPGEN/s:=.*:=./Parser/hostpgen:" \
162 Makefile.pre.in || die "sed failed"
163 fi
164
165 # Export CXX so it ends up in /usr/lib/python2.X/config/Makefile.
166 tc-export CXX
167 # The configure script fails to use pkg-config correctly.
168 # http://bugs.python.org/issue15506
169 export ac_cv_path_PKG_CONFIG=$(tc-getPKG_CONFIG)
170
171 # Set LDFLAGS so we link modules with -lpython2.7 correctly.
172 # Needed on FreeBSD unless Python 2.7 is already installed.
173 # Please query BSD team before removing this!
174 append-ldflags "-L."
175
176 local dbmliborder
177 if use gdbm; then
178 dbmliborder+="${dbmliborder:+:}gdbm"
179 fi
180 if use berkdb; then
181 dbmliborder+="${dbmliborder:+:}bdb"
182 fi
183
184 OPT="" econf \
185 --with-fpectl \
186 --enable-shared \
187 $(use_enable ipv6) \
188 $(use_with threads) \
189 $(use wide-unicode && echo "--enable-unicode=ucs4" || echo "--enable-unicode=ucs2") \
190 --infodir='${prefix}/share/info' \
191 --mandir='${prefix}/share/man' \
192 --with-dbmliborder="${dbmliborder}" \
193 --with-libc="" \
194 --enable-loadable-sqlite-extensions \
195 --with-system-expat \
196 --with-system-ffi
197 }
198
199 src_compile() {
200 emake EPYTHON="python${PV%%.*}" || die "emake failed"
201
202 # Work around bug 329499. See also bug 413751.
203 pax-mark m python
204 }
205
206 src_test() {
207 # Tests will not work when cross compiling.
208 if tc-is-cross-compiler; then
209 elog "Disabling tests due to crosscompiling."
210 return
211 fi
212
213 # Byte compiling should be enabled here.
214 # Otherwise test_import fails.
215 python_enable_pyc
216
217 # Skip failing tests.
218 local skipped_tests="distutils gdb"
219
220 for test in ${skipped_tests}; do
221 mv Lib/test/test_${test}.py "${T}"
222 done
223
224 # Rerun failed tests in verbose mode (regrtest -w).
225 emake test EXTRATESTOPTS="-w" < /dev/tty
226 local result="$?"
227
228 for test in ${skipped_tests}; do
229 mv "${T}/test_${test}.py" Lib/test
230 done
231
232 elog "The following tests have been skipped:"
233 for test in ${skipped_tests}; do
234 elog "test_${test}.py"
235 done
236
237 elog "If you would like to run them, you may:"
238 elog "cd '${EPREFIX}$(python_get_libdir)/test'"
239 elog "and run the tests separately."
240
241 python_disable_pyc
242
243 if [[ "${result}" -ne 0 ]]; then
244 die "emake test failed"
245 fi
246 }
247
248 src_install() {
249 [[ -z "${ED}" ]] && ED="${D%/}${EPREFIX}/"
250
251 emake DESTDIR="${D}" altinstall maninstall || die "emake altinstall maninstall failed"
252 python_clean_installation_image -q
253
254 sed -e "s/\(LDFLAGS=\).*/\1/" -i "${ED}$(python_get_libdir)/config/Makefile" || die "sed failed"
255
256 mv "${ED}usr/bin/python${SLOT}-config" "${ED}usr/bin/python-config-${SLOT}"
257
258 # Fix collisions between different slots of Python.
259 mv "${ED}usr/bin/2to3" "${ED}usr/bin/2to3-${SLOT}"
260 mv "${ED}usr/bin/pydoc" "${ED}usr/bin/pydoc${SLOT}"
261 mv "${ED}usr/bin/idle" "${ED}usr/bin/idle${SLOT}"
262 rm -f "${ED}usr/bin/smtpd.py"
263
264 if use build; then
265 rm -fr "${ED}usr/bin/idle${SLOT}" "${ED}$(python_get_libdir)/"{bsddb,dbhash.py,idlelib,lib-tk,sqlite3,test}
266 else
267 use elibc_uclibc && rm -fr "${ED}$(python_get_libdir)/"{bsddb/test,test}
268 use berkdb || rm -fr "${ED}$(python_get_libdir)/"{bsddb,dbhash.py,test/test_bsddb*}
269 use sqlite || rm -fr "${ED}$(python_get_libdir)/"{sqlite3,test/test_sqlite*}
270 use tk || rm -fr "${ED}usr/bin/idle${SLOT}" "${ED}$(python_get_libdir)/"{idlelib,lib-tk}
271 fi
272
273 use threads || rm -fr "${ED}$(python_get_libdir)/multiprocessing"
274 use wininst || rm -f "${ED}$(python_get_libdir)/distutils/command/"wininst-*.exe
275
276 dodoc Misc/{ACKS,HISTORY,NEWS} || die "dodoc failed"
277
278 if use examples; then
279 insinto /usr/share/doc/${PF}/examples
280 doins -r Tools || die "doins failed"
281 fi
282
283 newconfd "${FILESDIR}/pydoc.conf" pydoc-${SLOT} || die "newconfd failed"
284 newinitd "${FILESDIR}/pydoc.init" pydoc-${SLOT} || die "newinitd failed"
285 sed \
286 -e "s:@PYDOC_PORT_VARIABLE@:PYDOC${SLOT/./_}_PORT:" \
287 -e "s:@PYDOC@:pydoc${SLOT}:" \
288 -i "${ED}etc/conf.d/pydoc-${SLOT}" "${ED}etc/init.d/pydoc-${SLOT}" || die "sed failed"
289 }
290
291 pkg_preinst() {
292 if has_version "<${CATEGORY}/${PN}-${SLOT}" && ! has_version "${CATEGORY}/${PN}:2.7"; then
293 python_updater_warning="1"
294 fi
295 }
296
297 eselect_python_update() {
298 [[ -z "${EROOT}" || (! -d "${EROOT}" && -d "${ROOT}") ]] && EROOT="${ROOT%/}${EPREFIX}/"
299
300 if [[ -z "$(eselect python show)" || ! -f "${EROOT}usr/bin/$(eselect python show)" ]]; then
301 eselect python update
302 fi
303
304 if [[ -z "$(eselect python show --python${PV%%.*})" || ! -f "${EROOT}usr/bin/$(eselect python show --python${PV%%.*})" ]]; then
305 eselect python update --python${PV%%.*}
306 fi
307 }
308
309 pkg_postinst() {
310 eselect_python_update
311
312 python_mod_optimize -f -x "/(site-packages|test|tests)/" $(python_get_libdir)
313
314 if [[ "${python_updater_warning}" == "1" ]]; then
315 ewarn "You have just upgraded from an older version of Python."
316 ewarn "You should switch active version of Python ${PV%%.*} and run"
317 ewarn "'python-updater [options]' to rebuild Python modules."
318 fi
319 }
320
321 pkg_postrm() {
322 eselect_python_update
323
324 python_mod_cleanup $(python_get_libdir)
325 }

  ViewVC Help
Powered by ViewVC 1.1.20