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

Contents of /dev-lang/python/python-3.1.5.ebuild

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.18 - (show annotations) (download)
Sun Oct 14 14:48:25 2012 UTC (2 years, 3 months ago) by armin76
Branch: MAIN
Changes since 1.17: +2 -2 lines
ia64/m68k/s390/sh/sparc stable

(Portage version: 2.1.11.16/cvs/Linux ia64)

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

  ViewVC Help
Powered by ViewVC 1.1.20