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