Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 1 | # Copyright 1999-2012 Gentoo Foundation |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 3 | # $Header: /var/cvsroot/gentoo-x86/dev-lang/python/python-2.7.3-r3.ebuild,v 1.5 2012/12/19 18:03:41 floppym Exp $ |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 4 | |
| 5 | EAPI="2" |
| 6 | WANT_AUTOMAKE="none" |
| 7 | WANT_LIBTOOL="none" |
| 8 | |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 9 | inherit autotools eutils flag-o-matic multilib pax-utils python-utils-r1 toolchain-funcs multiprocessing |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 10 | |
| 11 | MY_P="Python-${PV}" |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 12 | PATCHSET_REVISION="1" |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 13 | |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 14 | DESCRIPTION="An interpreted, interactive, object-oriented programming language" |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 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" |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 20 | SLOT="2.7" |
| 21 | KEYWORDS="alpha amd64 arm hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd" |
| 22 | IUSE="-berkdb build doc elibc_uclibc examples gdbm hardened ipv6 +ncurses +readline sqlite +ssl +threads tk +wide-unicode wininst +xml" |
| 23 | |
| 24 | # Do not add a dependency on dev-lang/python to this ebuild. |
| 25 | # If you need to apply a patch which requires python for bootstrapping, please |
| 26 | # run the bootstrap code on your dev box and include the results in the |
| 27 | # patchset. See bug 447752. |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 28 | |
| 29 | RDEPEND="app-arch/bzip2 |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 30 | >=sys-libs/zlib-1.1.3 |
| 31 | virtual/libffi |
| 32 | virtual/libintl |
| 33 | !build? ( |
| 34 | berkdb? ( || ( |
| 35 | sys-libs/db:4.8 |
| 36 | sys-libs/db:4.7 |
| 37 | sys-libs/db:4.6 |
| 38 | sys-libs/db:4.5 |
| 39 | sys-libs/db:4.4 |
| 40 | sys-libs/db:4.3 |
| 41 | sys-libs/db:4.2 |
| 42 | ) ) |
| 43 | gdbm? ( sys-libs/gdbm ) |
| 44 | ncurses? ( |
| 45 | >=sys-libs/ncurses-5.2 |
| 46 | readline? ( >=sys-libs/readline-4.1 ) |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 47 | ) |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 48 | sqlite? ( >=dev-db/sqlite-3.3.8:3[extensions] ) |
| 49 | ssl? ( dev-libs/openssl ) |
| 50 | tk? ( |
| 51 | >=dev-lang/tk-8.0 |
| 52 | dev-tcltk/blt |
| 53 | ) |
| 54 | xml? ( >=dev-libs/expat-2.1 ) |
| 55 | ) |
| 56 | !!<sys-apps/portage-2.1.9" |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 57 | DEPEND="${RDEPEND} |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 58 | virtual/pkgconfig |
| 59 | >=sys-devel/autoconf-2.65 |
| 60 | !sys-devel/gcc[libffi]" |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 61 | RDEPEND+=" !build? ( app-misc/mime-types ) |
| 62 | doc? ( dev-python/python-docs:${SLOT} )" |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 63 | PDEPEND="app-admin/eselect-python |
| 64 | app-admin/python-updater" |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 65 | |
| 66 | S="${WORKDIR}/${MY_P}" |
| 67 | |
| 68 | pkg_setup() { |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 69 | if use berkdb; then |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 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." |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 74 | else |
| 75 | if has_version "=${CATEGORY}/${PN}-${PV%%.*}*[berkdb]"; then |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 76 | ewarn "You are migrating from =${CATEGORY}/${PN}-${PV%%.*}*[berkdb]" |
| 77 | ewarn "to =${CATEGORY}/${PN}-${PV%%.*}*[-berkdb]." |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 78 | ewarn "You might need to migrate your databases." |
| 79 | fi |
| 80 | fi |
| 81 | } |
| 82 | |
| 83 | src_prepare() { |
| 84 | # Ensure that internal copies of expat, libffi and zlib are not used. |
| 85 | rm -fr Modules/expat |
| 86 | rm -fr Modules/_ctypes/libffi* |
| 87 | rm -fr Modules/zlib |
| 88 | |
| 89 | local excluded_patches |
| 90 | if ! tc-is-cross-compiler; then |
| 91 | excluded_patches="*_all_crosscompile.patch" |
| 92 | fi |
| 93 | |
| 94 | EPATCH_EXCLUDE="${excluded_patches}" EPATCH_SUFFIX="patch" \ |
| 95 | epatch "${WORKDIR}/${PV}-${PATCHSET_REVISION}" |
| 96 | |
| 97 | # |
| 98 | # START: ChromiumOS specific changes |
| 99 | # |
| 100 | if tc-is-cross-compiler ; then |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 101 | epatch "${FILESDIR}"/python-2.7.3-cross-setup-sysroot.patch |
| 102 | epatch "${FILESDIR}"/python-2.7.3-cross-h2py.patch |
| 103 | epatch "${FILESDIR}"/python-2.7.3-cross-install-compile.patch |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 104 | sed -i 's:^python$EXE:${HOSTPYTHON}:' Lib/*/regen || die |
| 105 | fi |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 106 | epatch "${FILESDIR}"/python-2.7.3-cross-distutils.patch |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 107 | |
| 108 | sed -i -e "s:sys.exec_prefix]:sys.exec_prefix, '/usr/local']:g" \ |
| 109 | Lib/site.py || die "sed failed to add /usr/local to prefixes" |
| 110 | # |
| 111 | # END: ChromiumOS specific changes |
| 112 | # |
| 113 | |
| 114 | sed -i -e "s:@@GENTOO_LIBDIR@@:$(get_libdir):g" \ |
| 115 | Lib/distutils/command/install.py \ |
| 116 | Lib/distutils/sysconfig.py \ |
| 117 | Lib/site.py \ |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 118 | Lib/sysconfig.py \ |
| 119 | Lib/test/test_site.py \ |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 120 | Makefile.pre.in \ |
| 121 | Modules/Setup.dist \ |
| 122 | Modules/getpath.c \ |
| 123 | setup.py || die "sed failed to replace @@GENTOO_LIBDIR@@" |
| 124 | |
| 125 | eautoconf |
| 126 | eautoheader |
| 127 | } |
| 128 | |
| 129 | src_configure() { |
| 130 | if use build; then |
| 131 | # Disable extraneous modules with extra dependencies. |
| 132 | export PYTHON_DISABLE_MODULES="dbm _bsddb gdbm _curses _curses_panel readline _sqlite3 _tkinter _elementtree pyexpat" |
| 133 | export PYTHON_DISABLE_SSL="1" |
| 134 | else |
| 135 | # dbm module can be linked against berkdb or gdbm. |
| 136 | # Defaults to gdbm when both are enabled, #204343. |
| 137 | local disable |
| 138 | use berkdb || use gdbm || disable+=" dbm" |
| 139 | use berkdb || disable+=" _bsddb" |
| 140 | use gdbm || disable+=" gdbm" |
| 141 | use ncurses || disable+=" _curses _curses_panel" |
| 142 | use readline || disable+=" readline" |
| 143 | use sqlite || disable+=" _sqlite3" |
| 144 | use ssl || export PYTHON_DISABLE_SSL="1" |
| 145 | use tk || disable+=" _tkinter" |
| 146 | use xml || disable+=" _elementtree pyexpat" # _elementtree uses pyexpat. |
| 147 | export PYTHON_DISABLE_MODULES="${disable}" |
| 148 | |
| 149 | if ! use xml; then |
| 150 | ewarn "You have configured Python without XML support." |
| 151 | ewarn "This is NOT a recommended configuration as you" |
| 152 | ewarn "may face problems parsing any XML documents." |
| 153 | fi |
| 154 | fi |
| 155 | |
| 156 | if [[ -n "${PYTHON_DISABLE_MODULES}" ]]; then |
| 157 | einfo "Disabled modules: ${PYTHON_DISABLE_MODULES}" |
| 158 | fi |
| 159 | |
| 160 | if [[ "$(gcc-major-version)" -ge 4 ]]; then |
| 161 | append-flags -fwrapv |
| 162 | fi |
| 163 | |
| 164 | filter-flags -malign-double |
| 165 | |
| 166 | [[ "${ARCH}" == "alpha" ]] && append-flags -fPIC |
| 167 | |
| 168 | # https://bugs.gentoo.org/show_bug.cgi?id=50309 |
| 169 | if is-flagq -O3; then |
| 170 | is-flagq -fstack-protector-all && replace-flags -O3 -O2 |
| 171 | use hardened && replace-flags -O3 -O2 |
| 172 | fi |
| 173 | |
| 174 | # Run the configure scripts in parallel. |
| 175 | multijob_init |
| 176 | |
| 177 | mkdir -p "${WORKDIR}"/{${CBUILD},${CHOST}} |
| 178 | |
| 179 | if tc-is-cross-compiler; then |
| 180 | ( |
| 181 | multijob_child_init |
| 182 | cd "${WORKDIR}"/${CBUILD} >/dev/null |
| 183 | OPT="-O1" CFLAGS="" CPPFLAGS="" LDFLAGS="" CC="" \ |
| 184 | "${S}"/configure \ |
| 185 | --{build,host}=${CBUILD} \ |
| 186 | || die "cross-configure failed" |
| 187 | ) & |
| 188 | multijob_post_fork |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 189 | |
| 190 | # The configure script assumes it's buggy when cross-compiling. |
| 191 | export ac_cv_buggy_getaddrinfo=no |
| 192 | export ac_cv_have_long_long_format=yes |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 193 | fi |
| 194 | |
| 195 | # Export CXX so it ends up in /usr/lib/python2.X/config/Makefile. |
| 196 | tc-export CXX |
| 197 | # The configure script fails to use pkg-config correctly. |
| 198 | # http://bugs.python.org/issue15506 |
| 199 | export ac_cv_path_PKG_CONFIG=$(tc-getPKG_CONFIG) |
| 200 | |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 201 | # Set LDFLAGS so we link modules with -lpython2.7 correctly. |
| 202 | # Needed on FreeBSD unless Python 2.7 is already installed. |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 203 | # Please query BSD team before removing this! |
| 204 | append-ldflags "-L." |
| 205 | |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 206 | local dbmliborder |
| 207 | if use gdbm; then |
| 208 | dbmliborder+="${dbmliborder:+:}gdbm" |
| 209 | fi |
| 210 | if use berkdb; then |
| 211 | dbmliborder+="${dbmliborder:+:}bdb" |
| 212 | fi |
| 213 | |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 214 | cd "${WORKDIR}"/${CHOST} |
| 215 | ECONF_SOURCE=${S} OPT="" \ |
| 216 | econf \ |
| 217 | --with-fpectl \ |
| 218 | --enable-shared \ |
| 219 | $(use_enable ipv6) \ |
| 220 | $(use_with threads) \ |
| 221 | $(use wide-unicode && echo "--enable-unicode=ucs4" || echo "--enable-unicode=ucs2") \ |
| 222 | --infodir='${prefix}/share/info' \ |
| 223 | --mandir='${prefix}/share/man' \ |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 224 | --with-dbmliborder="${dbmliborder}" \ |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 225 | --with-libc="" \ |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 226 | --enable-loadable-sqlite-extensions \ |
| 227 | --with-system-expat \ |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 228 | --with-system-ffi |
| 229 | |
| 230 | if tc-is-cross-compiler; then |
| 231 | # Modify the Makefile.pre so we don't regen for the host/ one. |
| 232 | # We need to link the host python programs into $PWD and run |
| 233 | # them from here because the distutils sysconfig module will |
| 234 | # parse Makefile/etc... from argv[0], and we need it to pick |
| 235 | # up the target settings, not the host ones. |
| 236 | sed -i \ |
| 237 | -e '1iHOSTPYTHONPATH = ./hostpythonpath:' \ |
| 238 | -e '/^HOSTPYTHON/s:=.*:= ./hostpython:' \ |
| 239 | -e '/^HOSTPGEN/s:=.*:= ./Parser/hostpgen:' \ |
| 240 | Makefile{.pre,} || die "sed failed" |
| 241 | fi |
| 242 | |
| 243 | multijob_finish |
| 244 | } |
| 245 | |
| 246 | src_compile() { |
| 247 | if tc-is-cross-compiler; then |
| 248 | cd "${WORKDIR}"/${CBUILD} |
| 249 | # Disable as many modules as possible -- but we need a few to install. |
| 250 | PYTHON_DISABLE_MODULES=$( |
| 251 | sed -n "/Extension('/{s:^.*Extension('::;s:'.*::;p}" "${S}"/setup.py | \ |
| 252 | egrep -v '(unicodedata|time|cStringIO|_struct|binascii)' |
| 253 | ) \ |
| 254 | PTHON_DISABLE_SSL="1" \ |
| 255 | SYSROOT= \ |
| 256 | emake || die "cross-make failed" |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 257 | [[ -e build/lib.linux-x86_64-${SLOT}/unicodedata.so ]] || die |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 258 | # See comment in src_configure about these. |
| 259 | ln python ../${CHOST}/hostpython || die |
| 260 | ln Parser/pgen ../${CHOST}/Parser/hostpgen || die |
| 261 | ln -s ../${CBUILD}/build/lib.*/ ../${CHOST}/hostpythonpath || die |
| 262 | fi |
| 263 | |
| 264 | cd "${WORKDIR}"/${CHOST} |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 265 | default |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 266 | |
| 267 | # Work around bug 329499. See also bug 413751. |
| 268 | pax-mark m python |
| 269 | } |
| 270 | |
| 271 | src_test() { |
| 272 | # Tests will not work when cross compiling. |
| 273 | if tc-is-cross-compiler; then |
| 274 | elog "Disabling tests due to crosscompiling." |
| 275 | return |
| 276 | fi |
| 277 | |
| 278 | cd "${WORKDIR}"/${CHOST} |
| 279 | |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 280 | # Skip failing tests. |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 281 | local skipped_tests="distutils gdb" |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 282 | |
| 283 | for test in ${skipped_tests}; do |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 284 | mv "${S}"/Lib/test/test_${test}.py "${T}" |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 285 | done |
| 286 | |
| 287 | # Rerun failed tests in verbose mode (regrtest -w). |
| 288 | emake test EXTRATESTOPTS="-w" < /dev/tty |
| 289 | local result="$?" |
| 290 | |
| 291 | for test in ${skipped_tests}; do |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 292 | mv "${T}/test_${test}.py" "${S}"/Lib/test |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 293 | done |
| 294 | |
| 295 | elog "The following tests have been skipped:" |
| 296 | for test in ${skipped_tests}; do |
| 297 | elog "test_${test}.py" |
| 298 | done |
| 299 | |
| 300 | elog "If you would like to run them, you may:" |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 301 | elog "cd '${EPREFIX}/usr/$(get_libdir)/python${SLOT}/test'" |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 302 | elog "and run the tests separately." |
| 303 | |
| 304 | python_disable_pyc |
| 305 | |
| 306 | if [[ "${result}" -ne 0 ]]; then |
| 307 | die "emake test failed" |
| 308 | fi |
| 309 | } |
| 310 | |
| 311 | src_install() { |
| 312 | [[ -z "${ED}" ]] && ED="${D%/}${EPREFIX}/" |
| 313 | |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 314 | local libdir=${ED}/usr/$(get_libdir)/python${SLOT} |
| 315 | |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 316 | cd "${WORKDIR}"/${CHOST} |
| 317 | emake DESTDIR="${D}" altinstall maninstall || die "emake altinstall maninstall failed" |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 318 | |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 319 | sed -e "s/\(LDFLAGS=\).*/\1/" -i "${libdir}/config/Makefile" || die "sed failed" |
| 320 | |
| 321 | # Backwards compat with Gentoo divergence. |
| 322 | dosym python${SLOT}-config /usr/bin/python-config-${SLOT} || die |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 323 | |
| 324 | # Fix collisions between different slots of Python. |
| 325 | mv "${ED}usr/bin/2to3" "${ED}usr/bin/2to3-${SLOT}" |
| 326 | mv "${ED}usr/bin/pydoc" "${ED}usr/bin/pydoc${SLOT}" |
| 327 | mv "${ED}usr/bin/idle" "${ED}usr/bin/idle${SLOT}" |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 328 | rm -f "${ED}usr/bin/smtpd.py" |
| 329 | |
| 330 | if use build; then |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 331 | rm -fr "${ED}usr/bin/idle${SLOT}" "${libdir}/"{bsddb,dbhash.py,idlelib,lib-tk,sqlite3,test} |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 332 | else |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 333 | use elibc_uclibc && rm -fr "${libdir}/"{bsddb/test,test} |
| 334 | use berkdb || rm -fr "${libdir}/"{bsddb,dbhash.py,test/test_bsddb*} |
| 335 | use sqlite || rm -fr "${libdir}/"{sqlite3,test/test_sqlite*} |
| 336 | use tk || rm -fr "${ED}usr/bin/idle${SLOT}" "${libdir}/"{idlelib,lib-tk} |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 337 | fi |
| 338 | |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 339 | use threads || rm -fr "${libdir}/multiprocessing" |
| 340 | use wininst || rm -f "${libdir})/distutils/command/"wininst-*.exe |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 341 | |
| 342 | dodoc "${S}"/Misc/{ACKS,HISTORY,NEWS} || die "dodoc failed" |
| 343 | |
| 344 | if use examples; then |
| 345 | insinto /usr/share/doc/${PF}/examples |
| 346 | doins -r "${S}"/Tools || die "doins failed" |
| 347 | fi |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 348 | insinto /usr/share/gdb/auto-load/usr/$(get_libdir) #443510 |
| 349 | local libname=$(printf 'e:\n\t@echo $(INSTSONAME)\ninclude Makefile\n' | \ |
| 350 | emake --no-print-directory -s -f - 2>/dev/null) |
| 351 | newins "${S}"/Tools/gdb/libpython.py "${libname}"-gdb.py |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 352 | |
| 353 | newconfd "${FILESDIR}/pydoc.conf" pydoc-${SLOT} || die "newconfd failed" |
| 354 | newinitd "${FILESDIR}/pydoc.init" pydoc-${SLOT} || die "newinitd failed" |
| 355 | sed \ |
| 356 | -e "s:@PYDOC_PORT_VARIABLE@:PYDOC${SLOT/./_}_PORT:" \ |
| 357 | -e "s:@PYDOC@:pydoc${SLOT}:" \ |
| 358 | -i "${ED}etc/conf.d/pydoc-${SLOT}" "${ED}etc/init.d/pydoc-${SLOT}" || die "sed failed" |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 359 | |
| 360 | # for python-exec |
| 361 | python_export python${SLOT} EPYTHON PYTHON PYTHON_SITEDIR |
| 362 | |
| 363 | # if not using a cross-compiler, use the fresh binary |
| 364 | if ! tc-is-cross-compiler; then |
| 365 | local PYTHON=./python \ |
| 366 | LD_LIBRARY_PATH=${LD_LIBRARY_PATH+${LD_LIBRARY_PATH}:}. |
| 367 | export LD_LIBRARY_PATH |
| 368 | fi |
| 369 | |
| 370 | echo "EPYTHON='${EPYTHON}'" > epython.py |
| 371 | python_domodule epython.py |
| 372 | |
| 373 | # The sysconfig module will actually read the pyconfig.h at runtime to see what kind |
| 374 | # of functionality is enabled in the build. Deploy it behind the back of portage as |
| 375 | # need be. |
| 376 | ln "${ED}/usr/include/python${SLOT}"/pyconfig{.,_}h || die |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 377 | } |
| 378 | |
| 379 | pkg_preinst() { |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 380 | # Workaround https://bugs.gentoo.org/380569 |
| 381 | mkdir -p "${ED}/etc/env.d/python" |
| 382 | |
| 383 | # See end of src_install above. |
| 384 | mv "${ED}/usr/include/python${SLOT}/pyconfig_h" "${T}/" || die |
| 385 | |
| 386 | if has_version "<${CATEGORY}/${PN}-${SLOT}" && ! has_version "${CATEGORY}/${PN}:2.7"; then |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 387 | python_updater_warning="1" |
| 388 | fi |
| 389 | } |
| 390 | |
| 391 | eselect_python_update() { |
| 392 | [[ -z "${EROOT}" || (! -d "${EROOT}" && -d "${ROOT}") ]] && EROOT="${ROOT%/}${EPREFIX}/" |
| 393 | |
| 394 | if [[ -z "$(eselect python show)" || ! -f "${EROOT}usr/bin/$(eselect python show)" ]]; then |
| 395 | eselect python update |
| 396 | fi |
| 397 | |
| 398 | if [[ -z "$(eselect python show --python${PV%%.*})" || ! -f "${EROOT}usr/bin/$(eselect python show --python${PV%%.*})" ]]; then |
| 399 | eselect python update --python${PV%%.*} |
| 400 | fi |
| 401 | } |
| 402 | |
| 403 | pkg_postinst() { |
| 404 | eselect_python_update |
| 405 | |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 406 | if [[ "${python_updater_warning}" == "1" ]]; then |
| 407 | ewarn "You have just upgraded from an older version of Python." |
| 408 | ewarn "You should switch active version of Python ${PV%%.*} and run" |
| 409 | ewarn "'python-updater [options]' to rebuild Python modules." |
| 410 | fi |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame^] | 411 | |
| 412 | if [[ ! -e ${EROOT}/usr/include/python${SLOT}/pyconfig.h ]] ; then |
| 413 | # See pkg_preinst above for details. |
| 414 | install -D -m644 "${T}/pyconfig_h" "${EROOT}/usr/include/python${SLOT}/pyconfig.h" || die |
| 415 | fi |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 416 | } |
| 417 | |
| 418 | pkg_postrm() { |
| 419 | eselect_python_update |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 420 | } |