blob: 922537a7e01f7d1717c2af9633ee08f553d91286 [file] [log] [blame]
Mike Frysinger51f0d522015-11-21 00:11:17 +00001# Copyright 1999-2015 Gentoo Foundation
Mike Frysinger682d0652012-07-30 11:38:25 -04002# Distributed under the terms of the GNU General Public License v2
Mike Frysinger51f0d522015-11-21 00:11:17 +00003# $Header: /var/cvsroot/gentoo-x86/dev-lang/python/python-2.7.10.ebuild,v 1.2 2015/06/29 17:26:27 floppym Exp $
Mike Frysinger682d0652012-07-30 11:38:25 -04004
Cheng-Yi Chiangb88f6962015-08-06 13:49:23 +00005# ******************************* README ***************************************
6# WARNING! ANY CHANGE TO THIS FILE *MUST* BE ACCOMPANIED BY A CHANGE TO
7# chromeos-base/dev-install's ebuild, which depends on python indirectly.
8# Otherwise, incremental builds will break. See crbug.com/489895.
9# ******************************************************************************
10
Mike Frysinger51f0d522015-11-21 00:11:17 +000011EAPI="4"
Mike Frysinger682d0652012-07-30 11:38:25 -040012WANT_LIBTOOL="none"
13
Mike Frysinger4cfb44a2013-03-18 22:37:33 -040014inherit autotools eutils flag-o-matic multilib pax-utils python-utils-r1 toolchain-funcs multiprocessing
Mike Frysinger682d0652012-07-30 11:38:25 -040015
16MY_P="Python-${PV}"
Mike Frysinger51f0d522015-11-21 00:11:17 +000017PATCHSET_VERSION="2.7.10-0"
Mike Frysinger682d0652012-07-30 11:38:25 -040018
Mike Frysinger4cfb44a2013-03-18 22:37:33 -040019DESCRIPTION="An interpreted, interactive, object-oriented programming language"
Mike Frysinger682d0652012-07-30 11:38:25 -040020HOMEPAGE="http://www.python.org/"
Mike Frysinger51f0d522015-11-21 00:11:17 +000021SRC_URI="http://www.python.org/ftp/python/${PV}/${MY_P}.tar.xz
22 http://dev.gentoo.org/~floppym/python/python-gentoo-patches-${PATCHSET_VERSION}.tar.xz"
Mike Frysinger682d0652012-07-30 11:38:25 -040023
24LICENSE="PSF-2"
Mike Frysinger4cfb44a2013-03-18 22:37:33 -040025SLOT="2.7"
Mike Frysinger65332152014-02-14 13:55:27 -050026KEYWORDS="*"
Mike Frysinger4cfb44a2013-03-18 22:37:33 -040027IUSE="-berkdb build doc elibc_uclibc examples gdbm hardened ipv6 +ncurses +readline sqlite +ssl +threads tk +wide-unicode wininst +xml"
28
29# Do not add a dependency on dev-lang/python to this ebuild.
30# If you need to apply a patch which requires python for bootstrapping, please
31# run the bootstrap code on your dev box and include the results in the
32# patchset. See bug 447752.
Mike Frysinger682d0652012-07-30 11:38:25 -040033
34RDEPEND="app-arch/bzip2
Mike Frysinger4cfb44a2013-03-18 22:37:33 -040035 >=sys-libs/zlib-1.1.3
36 virtual/libffi
37 virtual/libintl
38 !build? (
39 berkdb? ( || (
Mike Frysinger51f0d522015-11-21 00:11:17 +000040 sys-libs/db:5.3
41 sys-libs/db:5.2
42 sys-libs/db:5.1
43 sys-libs/db:5.0
Mike Frysinger4cfb44a2013-03-18 22:37:33 -040044 sys-libs/db:4.8
45 sys-libs/db:4.7
46 sys-libs/db:4.6
47 sys-libs/db:4.5
48 sys-libs/db:4.4
49 sys-libs/db:4.3
50 sys-libs/db:4.2
51 ) )
52 gdbm? ( sys-libs/gdbm )
53 ncurses? (
54 >=sys-libs/ncurses-5.2
55 readline? ( >=sys-libs/readline-4.1 )
Mike Frysinger682d0652012-07-30 11:38:25 -040056 )
Ryan Sleevi1a745162014-10-27 18:14:49 -070057 sqlite? ( >=dev-db/sqlite-3.3.8:3 )
Mike Frysinger4cfb44a2013-03-18 22:37:33 -040058 ssl? ( dev-libs/openssl )
59 tk? (
60 >=dev-lang/tk-8.0
61 dev-tcltk/blt
Mike Frysinger51f0d522015-11-21 00:11:17 +000062 dev-tcltk/tix
Mike Frysinger4cfb44a2013-03-18 22:37:33 -040063 )
64 xml? ( >=dev-libs/expat-2.1 )
65 )
66 !!<sys-apps/portage-2.1.9"
Mike Frysinger682d0652012-07-30 11:38:25 -040067DEPEND="${RDEPEND}
Mike Frysinger4cfb44a2013-03-18 22:37:33 -040068 virtual/pkgconfig
69 >=sys-devel/autoconf-2.65
70 !sys-devel/gcc[libffi]"
Mike Frysinger682d0652012-07-30 11:38:25 -040071RDEPEND+=" !build? ( app-misc/mime-types )
72 doc? ( dev-python/python-docs:${SLOT} )"
Daniel Kurtzd47b2922017-07-17 17:47:39 +080073PDEPEND="app-eselect/eselect-python
Mike Frysinger51f0d522015-11-21 00:11:17 +000074 app-admin/python-updater"
Mike Frysinger682d0652012-07-30 11:38:25 -040075
76S="${WORKDIR}/${MY_P}"
77
78pkg_setup() {
Mike Frysinger682d0652012-07-30 11:38:25 -040079 if use berkdb; then
Mike Frysinger4cfb44a2013-03-18 22:37:33 -040080 ewarn "'bsddb' module is out-of-date and no longer maintained inside"
81 ewarn "dev-lang/python. 'bsddb' and 'dbhash' modules have been additionally"
82 ewarn "removed in Python 3. A maintained alternative of 'bsddb3' module"
83 ewarn "is provided by dev-python/bsddb3."
Mike Frysinger682d0652012-07-30 11:38:25 -040084 else
85 if has_version "=${CATEGORY}/${PN}-${PV%%.*}*[berkdb]"; then
Mike Frysinger4cfb44a2013-03-18 22:37:33 -040086 ewarn "You are migrating from =${CATEGORY}/${PN}-${PV%%.*}*[berkdb]"
87 ewarn "to =${CATEGORY}/${PN}-${PV%%.*}*[-berkdb]."
Mike Frysinger682d0652012-07-30 11:38:25 -040088 ewarn "You might need to migrate your databases."
89 fi
90 fi
91}
92
93src_prepare() {
Tim Zwiebelab07eb22017-06-03 03:19:57 -070094 # According to the comments at the top of cgi.py, Linux vendors need to
95 # patch the shebang in cgi.py. We'll ignore the comment about not using
96 # "/usr/bin/env python" and use it anyway.
97 sed -i -e '1 s:^#!.*$:#! /usr/bin/env python:' Lib/cgi.py || die
98
Mike Frysinger682d0652012-07-30 11:38:25 -040099 # Ensure that internal copies of expat, libffi and zlib are not used.
Mike Frysinger51f0d522015-11-21 00:11:17 +0000100 rm -r Modules/expat || die
101 rm -r Modules/_ctypes/libffi* || die
102 rm -r Modules/zlib || die
Mike Frysinger682d0652012-07-30 11:38:25 -0400103
Mike Frysinger51f0d522015-11-21 00:11:17 +0000104 if tc-is-cross-compiler; then
105 local EPATCH_EXCLUDE="*_regenerate_platform-specific_modules.patch"
Mike Frysinger682d0652012-07-30 11:38:25 -0400106 fi
107
Mike Frysinger51f0d522015-11-21 00:11:17 +0000108 EPATCH_SUFFIX="patch" epatch "${WORKDIR}/patches"
Mike Frysinger682d0652012-07-30 11:38:25 -0400109
110 #
111 # START: ChromiumOS specific changes
112 #
113 if tc-is-cross-compiler ; then
Mike Frysinger51f0d522015-11-21 00:11:17 +0000114 epatch "${FILESDIR}"/python-2.7.10-cross-h2py.patch
115 epatch "${FILESDIR}"/python-2.7.10-cross-hack-compiler.patch
Mike Frysinger682d0652012-07-30 11:38:25 -0400116 sed -i 's:^python$EXE:${HOSTPYTHON}:' Lib/*/regen || die
117 fi
Mike Frysinger51f0d522015-11-21 00:11:17 +0000118 epatch "${FILESDIR}"/python-2.7.10-cross-setup-sysroot.patch
119 epatch "${FILESDIR}"/python-2.7.10-cross-distutils.patch
Paul Hobbs43d07e62015-05-14 16:43:16 -0700120 epatch "${FILESDIR}"/python-2.7.3-unique-semaphore-name.patch
Mike Frysinger51f0d522015-11-21 00:11:17 +0000121 epatch "${FILESDIR}"/python-2.7.10-ldshared.patch
Manoj Gupta85657702018-11-05 18:26:27 -0800122 epatch "${FILESDIR}"/python-2.7.17-getentropy.patch
Yunlian Jiang871d0072018-07-24 11:11:01 -0700123 epatch "${FILESDIR}"/2.7-disable-nis.patch
Mike Frysingereb047962014-04-06 10:08:56 -0400124 # Undo the @libdir@ change for portage's pym folder as it is always
125 # installed into /usr/lib/ and not the abi libdir.
126 sed -i \
127 -e '/portage.*pym/s:@@GENTOO_LIBDIR@@:lib:g' \
128 Lib/site.py || die
Mike Frysinger682d0652012-07-30 11:38:25 -0400129
130 sed -i -e "s:sys.exec_prefix]:sys.exec_prefix, '/usr/local']:g" \
131 Lib/site.py || die "sed failed to add /usr/local to prefixes"
132 #
133 # END: ChromiumOS specific changes
134 #
135
Mike Frysinger51f0d522015-11-21 00:11:17 +0000136 # Fix for cross-compiling.
137 epatch "${FILESDIR}/python-2.7.5-nonfatal-compileall.patch"
138 epatch "${FILESDIR}/python-2.7.9-ncurses-pkg-config.patch"
139
Mike Frysinger682d0652012-07-30 11:38:25 -0400140 sed -i -e "s:@@GENTOO_LIBDIR@@:$(get_libdir):g" \
141 Lib/distutils/command/install.py \
142 Lib/distutils/sysconfig.py \
143 Lib/site.py \
Mike Frysinger4cfb44a2013-03-18 22:37:33 -0400144 Lib/sysconfig.py \
145 Lib/test/test_site.py \
Mike Frysinger682d0652012-07-30 11:38:25 -0400146 Makefile.pre.in \
147 Modules/Setup.dist \
148 Modules/getpath.c \
149 setup.py || die "sed failed to replace @@GENTOO_LIBDIR@@"
150
Mike Frysinger51f0d522015-11-21 00:11:17 +0000151 epatch_user
152
153 eautoreconf
Mike Frysinger682d0652012-07-30 11:38:25 -0400154}
155
156src_configure() {
157 if use build; then
158 # Disable extraneous modules with extra dependencies.
159 export PYTHON_DISABLE_MODULES="dbm _bsddb gdbm _curses _curses_panel readline _sqlite3 _tkinter _elementtree pyexpat"
160 export PYTHON_DISABLE_SSL="1"
161 else
162 # dbm module can be linked against berkdb or gdbm.
163 # Defaults to gdbm when both are enabled, #204343.
164 local disable
165 use berkdb || use gdbm || disable+=" dbm"
166 use berkdb || disable+=" _bsddb"
167 use gdbm || disable+=" gdbm"
168 use ncurses || disable+=" _curses _curses_panel"
169 use readline || disable+=" readline"
170 use sqlite || disable+=" _sqlite3"
171 use ssl || export PYTHON_DISABLE_SSL="1"
172 use tk || disable+=" _tkinter"
173 use xml || disable+=" _elementtree pyexpat" # _elementtree uses pyexpat.
174 export PYTHON_DISABLE_MODULES="${disable}"
175
176 if ! use xml; then
177 ewarn "You have configured Python without XML support."
178 ewarn "This is NOT a recommended configuration as you"
179 ewarn "may face problems parsing any XML documents."
180 fi
181 fi
182
183 if [[ -n "${PYTHON_DISABLE_MODULES}" ]]; then
184 einfo "Disabled modules: ${PYTHON_DISABLE_MODULES}"
185 fi
186
187 if [[ "$(gcc-major-version)" -ge 4 ]]; then
188 append-flags -fwrapv
189 fi
190
191 filter-flags -malign-double
192
193 [[ "${ARCH}" == "alpha" ]] && append-flags -fPIC
194
195 # https://bugs.gentoo.org/show_bug.cgi?id=50309
196 if is-flagq -O3; then
197 is-flagq -fstack-protector-all && replace-flags -O3 -O2
198 use hardened && replace-flags -O3 -O2
199 fi
200
Mike Frysinger682d0652012-07-30 11:38:25 -0400201 if tc-is-cross-compiler; then
Mike Frysinger51f0d522015-11-21 00:11:17 +0000202 # Force some tests that try to poke fs paths.
203 export ac_cv_file__dev_ptc=no
204 export ac_cv_file__dev_ptmx=yes
Mike Frysinger682d0652012-07-30 11:38:25 -0400205 fi
206
207 # Export CXX so it ends up in /usr/lib/python2.X/config/Makefile.
208 tc-export CXX
209 # The configure script fails to use pkg-config correctly.
210 # http://bugs.python.org/issue15506
211 export ac_cv_path_PKG_CONFIG=$(tc-getPKG_CONFIG)
212
Mike Frysinger4cfb44a2013-03-18 22:37:33 -0400213 # Set LDFLAGS so we link modules with -lpython2.7 correctly.
214 # Needed on FreeBSD unless Python 2.7 is already installed.
Mike Frysinger682d0652012-07-30 11:38:25 -0400215 # Please query BSD team before removing this!
216 append-ldflags "-L."
217
Mike Frysinger4cfb44a2013-03-18 22:37:33 -0400218 local dbmliborder
219 if use gdbm; then
220 dbmliborder+="${dbmliborder:+:}gdbm"
221 fi
222 if use berkdb; then
223 dbmliborder+="${dbmliborder:+:}bdb"
224 fi
225
Mike Frysinger51f0d522015-11-21 00:11:17 +0000226 BUILD_DIR="${WORKDIR}/${CHOST}"
227 mkdir -p "${BUILD_DIR}" || die
228 cd "${BUILD_DIR}" || die
229
230 ECONF_SOURCE="${S}" OPT="" \
Mike Frysinger682d0652012-07-30 11:38:25 -0400231 econf \
232 --with-fpectl \
233 --enable-shared \
234 $(use_enable ipv6) \
235 $(use_with threads) \
236 $(use wide-unicode && echo "--enable-unicode=ucs4" || echo "--enable-unicode=ucs2") \
237 --infodir='${prefix}/share/info' \
238 --mandir='${prefix}/share/man' \
Mike Frysinger4cfb44a2013-03-18 22:37:33 -0400239 --with-dbmliborder="${dbmliborder}" \
Mike Frysinger682d0652012-07-30 11:38:25 -0400240 --with-libc="" \
Mike Frysinger4cfb44a2013-03-18 22:37:33 -0400241 --enable-loadable-sqlite-extensions \
242 --with-system-expat \
Mike Frysinger51f0d522015-11-21 00:11:17 +0000243 --with-system-ffi \
244 --without-ensurepip
Mike Frysinger682d0652012-07-30 11:38:25 -0400245
Mike Frysinger51f0d522015-11-21 00:11:17 +0000246 if use threads && grep -q "#define POSIX_SEMAPHORES_NOT_ENABLED 1" pyconfig.h; then
247 eerror "configure has detected that the sem_open function is broken."
248 eerror "Please ensure that /dev/shm is mounted as a tmpfs with mode 1777."
249 die "Broken sem_open function (bug 496328)"
Mike Frysinger682d0652012-07-30 11:38:25 -0400250 fi
Mike Frysinger682d0652012-07-30 11:38:25 -0400251}
252
253src_compile() {
Mike Frysinger51f0d522015-11-21 00:11:17 +0000254 # Avoid invoking pgen for cross-compiles.
255 touch Include/graminit.h Python/graminit.c
256
257 cd "${BUILD_DIR}" || die
258 emake
259
260 # Work around bug 329499. See also bug 413751 and 457194.
261 if has_version dev-libs/libffi[pax_kernel]; then
262 pax-mark E python
263 else
264 pax-mark m python
Mike Frysinger682d0652012-07-30 11:38:25 -0400265 fi
Mike Frysinger682d0652012-07-30 11:38:25 -0400266}
267
268src_test() {
269 # Tests will not work when cross compiling.
270 if tc-is-cross-compiler; then
271 elog "Disabling tests due to crosscompiling."
272 return
273 fi
274
Mike Frysinger51f0d522015-11-21 00:11:17 +0000275 cd "${BUILD_DIR}" || die
Mike Frysinger682d0652012-07-30 11:38:25 -0400276
Mike Frysinger682d0652012-07-30 11:38:25 -0400277 # Skip failing tests.
Mike Frysinger4cfb44a2013-03-18 22:37:33 -0400278 local skipped_tests="distutils gdb"
Mike Frysinger682d0652012-07-30 11:38:25 -0400279
280 for test in ${skipped_tests}; do
Mike Frysinger4cfb44a2013-03-18 22:37:33 -0400281 mv "${S}"/Lib/test/test_${test}.py "${T}"
Mike Frysinger682d0652012-07-30 11:38:25 -0400282 done
283
284 # Rerun failed tests in verbose mode (regrtest -w).
285 emake test EXTRATESTOPTS="-w" < /dev/tty
286 local result="$?"
287
288 for test in ${skipped_tests}; do
Mike Frysinger4cfb44a2013-03-18 22:37:33 -0400289 mv "${T}/test_${test}.py" "${S}"/Lib/test
Mike Frysinger682d0652012-07-30 11:38:25 -0400290 done
291
292 elog "The following tests have been skipped:"
293 for test in ${skipped_tests}; do
294 elog "test_${test}.py"
295 done
296
297 elog "If you would like to run them, you may:"
Mike Frysinger4cfb44a2013-03-18 22:37:33 -0400298 elog "cd '${EPREFIX}/usr/$(get_libdir)/python${SLOT}/test'"
Mike Frysinger682d0652012-07-30 11:38:25 -0400299 elog "and run the tests separately."
300
301 python_disable_pyc
302
303 if [[ "${result}" -ne 0 ]]; then
304 die "emake test failed"
305 fi
306}
307
308src_install() {
Mike Frysinger4cfb44a2013-03-18 22:37:33 -0400309 local libdir=${ED}/usr/$(get_libdir)/python${SLOT}
310
Mike Frysinger51f0d522015-11-21 00:11:17 +0000311 cd "${BUILD_DIR}" || die
312 emake DESTDIR="${D}" altinstall
Mike Frysinger682d0652012-07-30 11:38:25 -0400313
Mike Frysinger4cfb44a2013-03-18 22:37:33 -0400314 sed -e "s/\(LDFLAGS=\).*/\1/" -i "${libdir}/config/Makefile" || die "sed failed"
315
316 # Backwards compat with Gentoo divergence.
Mike Frysinger51f0d522015-11-21 00:11:17 +0000317 dosym python${SLOT}-config /usr/bin/python-config-${SLOT}
Mike Frysinger682d0652012-07-30 11:38:25 -0400318
319 # Fix collisions between different slots of Python.
320 mv "${ED}usr/bin/2to3" "${ED}usr/bin/2to3-${SLOT}"
321 mv "${ED}usr/bin/pydoc" "${ED}usr/bin/pydoc${SLOT}"
322 mv "${ED}usr/bin/idle" "${ED}usr/bin/idle${SLOT}"
Mike Frysinger682d0652012-07-30 11:38:25 -0400323 rm -f "${ED}usr/bin/smtpd.py"
324
Chad Versace016e8732018-10-26 12:55:13 -0700325 local abiver="python2.7"
326
Mike Frysinger682d0652012-07-30 11:38:25 -0400327 if use build; then
Mike Frysinger4cfb44a2013-03-18 22:37:33 -0400328 rm -fr "${ED}usr/bin/idle${SLOT}" "${libdir}/"{bsddb,dbhash.py,idlelib,lib-tk,sqlite3,test}
Mike Frysinger682d0652012-07-30 11:38:25 -0400329 else
Mike Frysinger51f0d522015-11-21 00:11:17 +0000330 use berkdb || rm -r "${libdir}/"{bsddb,dbhash.py,test/test_bsddb*} || die
331 use sqlite || rm -r "${libdir}/"{sqlite3,test/test_sqlite*} || die
332 use tk || rm -r "${ED}usr/bin/idle${SLOT}" "${libdir}/"{idlelib,lib-tk} || die
Mike Frysinger4cfb44a2013-03-18 22:37:33 -0400333 use elibc_uclibc && rm -fr "${libdir}/"{bsddb/test,test}
Mike Frysinger682d0652012-07-30 11:38:25 -0400334 fi
335
Mike Frysinger51f0d522015-11-21 00:11:17 +0000336 use threads || rm -r "${libdir}/multiprocessing" || die
337 use wininst || rm -r "${libdir}/distutils/command/"wininst-*.exe || die
Mike Frysinger682d0652012-07-30 11:38:25 -0400338
Mike Frysinger51f0d522015-11-21 00:11:17 +0000339 dodoc "${S}"/Misc/{ACKS,HISTORY,NEWS}
Mike Frysinger682d0652012-07-30 11:38:25 -0400340
341 if use examples; then
342 insinto /usr/share/doc/${PF}/examples
Mike Frysinger51f0d522015-11-21 00:11:17 +0000343 doins -r "${S}"/Tools
Mike Frysinger682d0652012-07-30 11:38:25 -0400344 fi
Mike Frysinger4cfb44a2013-03-18 22:37:33 -0400345 insinto /usr/share/gdb/auto-load/usr/$(get_libdir) #443510
346 local libname=$(printf 'e:\n\t@echo $(INSTSONAME)\ninclude Makefile\n' | \
347 emake --no-print-directory -s -f - 2>/dev/null)
348 newins "${S}"/Tools/gdb/libpython.py "${libname}"-gdb.py
Mike Frysinger682d0652012-07-30 11:38:25 -0400349
Mike Frysinger51f0d522015-11-21 00:11:17 +0000350 newconfd "${FILESDIR}/pydoc.conf" pydoc-${SLOT}
351 newinitd "${FILESDIR}/pydoc.init" pydoc-${SLOT}
Mike Frysinger682d0652012-07-30 11:38:25 -0400352 sed \
353 -e "s:@PYDOC_PORT_VARIABLE@:PYDOC${SLOT/./_}_PORT:" \
354 -e "s:@PYDOC@:pydoc${SLOT}:" \
355 -i "${ED}etc/conf.d/pydoc-${SLOT}" "${ED}etc/init.d/pydoc-${SLOT}" || die "sed failed"
Mike Frysinger4cfb44a2013-03-18 22:37:33 -0400356
357 # for python-exec
Chad Versace016e8732018-10-26 12:55:13 -0700358 python_export python${SLOT} EPYTHON PYTHON PYTHON_SITEDIR PYTHON_SCRIPTDIR
Mike Frysinger4cfb44a2013-03-18 22:37:33 -0400359
360 # if not using a cross-compiler, use the fresh binary
361 if ! tc-is-cross-compiler; then
Mike Frysinger51f0d522015-11-21 00:11:17 +0000362 local PYTHON=./python
363 local -x LD_LIBRARY_PATH=${LD_LIBRARY_PATH+${LD_LIBRARY_PATH}:}.
Mike Frysinger4cfb44a2013-03-18 22:37:33 -0400364 fi
365
366 echo "EPYTHON='${EPYTHON}'" > epython.py
367 python_domodule epython.py
368
Chad Versace016e8732018-10-26 12:55:13 -0700369 # python-exec wrapping support
370 local pymajor=${SLOT%.*}
371 mkdir -p "${D}${PYTHON_SCRIPTDIR}" || die
372
373 # python-exec: python, pythonX
374 dosym "../../../bin/${abiver}" \
375 "${PYTHON_SCRIPTDIR}/python${pymajor}"
376 dosym "python${pymajor}" "${PYTHON_SCRIPTDIR}/python"
377
378 # python-exec: python-config, python-configX
379 #
380 # Note: we need to create a wrapper rather than symlinking it due
381 # to some random dirname(argv[0]) magic performed by python-config.
382 cat > "${D}${PYTHON_SCRIPTDIR}/python${pymajor}-config" <<-EOF || die
383 #!/bin/sh
384 exec "${abiver}-config" "\${@}"
385 EOF
386 # Must strip EPREFIX because fperms prepends ED.
387 fperms 755 "${PYTHON_SCRIPTDIR#$EPREFIX}/python${pymajor}-config"
388 dosym "python${pymajor}-config" \
389 "${PYTHON_SCRIPTDIR}/python-config"
390
391 # python-exec: pydoc, pydocX
392 dosym "../../../bin/pydoc${SLOT}" \
393 "${PYTHON_SCRIPTDIR}/pydoc${pymajor}"
394 dosym "pydoc${pymajor}" "${PYTHON_SCRIPTDIR}/pydoc"
395
396 # python-exec: 2to3
397 dosym "../../../bin/2to3-${SLOT}" \
398 "${PYTHON_SCRIPTDIR}/2to3"
399
Mike Frysinger4cfb44a2013-03-18 22:37:33 -0400400 # The sysconfig module will actually read the pyconfig.h at runtime to see what kind
401 # of functionality is enabled in the build. Deploy it behind the back of portage as
402 # need be.
Mike Frysingerd7685db2013-04-06 02:03:53 -0400403 ln "${ED}/usr/include/python${SLOT}/pyconfig.h" "${libdir}/pyconfig_h" || die
404
405 # Workaround https://bugs.gentoo.org/380569
406 keepdir /etc/env.d/python
Mike Frysinger682d0652012-07-30 11:38:25 -0400407}
408
409pkg_preinst() {
Mike Frysinger4cfb44a2013-03-18 22:37:33 -0400410 if has_version "<${CATEGORY}/${PN}-${SLOT}" && ! has_version "${CATEGORY}/${PN}:2.7"; then
Mike Frysinger682d0652012-07-30 11:38:25 -0400411 python_updater_warning="1"
412 fi
413}
414
415eselect_python_update() {
Mike Frysinger682d0652012-07-30 11:38:25 -0400416 if [[ -z "$(eselect python show)" || ! -f "${EROOT}usr/bin/$(eselect python show)" ]]; then
417 eselect python update
418 fi
419
420 if [[ -z "$(eselect python show --python${PV%%.*})" || ! -f "${EROOT}usr/bin/$(eselect python show --python${PV%%.*})" ]]; then
421 eselect python update --python${PV%%.*}
422 fi
423}
424
425pkg_postinst() {
426 eselect_python_update
427
Mike Frysinger682d0652012-07-30 11:38:25 -0400428 if [[ "${python_updater_warning}" == "1" ]]; then
429 ewarn "You have just upgraded from an older version of Python."
430 ewarn "You should switch active version of Python ${PV%%.*} and run"
431 ewarn "'python-updater [options]' to rebuild Python modules."
432 fi
Mike Frysinger4cfb44a2013-03-18 22:37:33 -0400433
Mike Frysingerd7685db2013-04-06 02:03:53 -0400434 local pyconfig="${EROOT}/usr/$(get_libdir)/python${SLOT}/pyconfig_h"
Mike Frysinger4cfb44a2013-03-18 22:37:33 -0400435 if [[ ! -e ${EROOT}/usr/include/python${SLOT}/pyconfig.h ]] ; then
436 # See pkg_preinst above for details.
Mike Frysingerd7685db2013-04-06 02:03:53 -0400437 install -D -m644 "${pyconfig}" "${EROOT}/usr/include/python${SLOT}/pyconfig.h" || die
Mike Frysinger4cfb44a2013-03-18 22:37:33 -0400438 fi
Mike Frysingerd7685db2013-04-06 02:03:53 -0400439 rm "${pyconfig}" || die
Mike Frysinger682d0652012-07-30 11:38:25 -0400440}
441
442pkg_postrm() {
443 eselect_python_update
Mike Frysinger682d0652012-07-30 11:38:25 -0400444}