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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.20