Mike Frysinger | 51f0d52 | 2015-11-21 00:11:17 +0000 | [diff] [blame] | 1 | # Copyright 1999-2015 Gentoo Foundation |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 2 | # Distributed under the terms of the GNU General Public License v2 |
Mike Frysinger | 51f0d52 | 2015-11-21 00:11:17 +0000 | [diff] [blame] | 3 | # $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 Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 4 | |
Cheng-Yi Chiang | b88f696 | 2015-08-06 13:49:23 +0000 | [diff] [blame] | 5 | # ******************************* 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 Frysinger | 51f0d52 | 2015-11-21 00:11:17 +0000 | [diff] [blame] | 11 | EAPI="4" |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 12 | WANT_LIBTOOL="none" |
| 13 | |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame] | 14 | 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] | 15 | |
| 16 | MY_P="Python-${PV}" |
Mike Frysinger | 51f0d52 | 2015-11-21 00:11:17 +0000 | [diff] [blame] | 17 | PATCHSET_VERSION="2.7.10-0" |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 18 | |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame] | 19 | DESCRIPTION="An interpreted, interactive, object-oriented programming language" |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 20 | HOMEPAGE="http://www.python.org/" |
Mike Frysinger | 51f0d52 | 2015-11-21 00:11:17 +0000 | [diff] [blame] | 21 | SRC_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 Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 23 | |
| 24 | LICENSE="PSF-2" |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame] | 25 | SLOT="2.7" |
Mike Frysinger | 6533215 | 2014-02-14 13:55:27 -0500 | [diff] [blame] | 26 | KEYWORDS="*" |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame] | 27 | IUSE="-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 Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 33 | |
| 34 | RDEPEND="app-arch/bzip2 |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame] | 35 | >=sys-libs/zlib-1.1.3 |
| 36 | virtual/libffi |
| 37 | virtual/libintl |
| 38 | !build? ( |
| 39 | berkdb? ( || ( |
Mike Frysinger | 51f0d52 | 2015-11-21 00:11:17 +0000 | [diff] [blame] | 40 | sys-libs/db:5.3 |
| 41 | sys-libs/db:5.2 |
| 42 | sys-libs/db:5.1 |
| 43 | sys-libs/db:5.0 |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame] | 44 | 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 Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 56 | ) |
Ryan Sleevi | 1a74516 | 2014-10-27 18:14:49 -0700 | [diff] [blame] | 57 | sqlite? ( >=dev-db/sqlite-3.3.8:3 ) |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame] | 58 | ssl? ( dev-libs/openssl ) |
| 59 | tk? ( |
| 60 | >=dev-lang/tk-8.0 |
| 61 | dev-tcltk/blt |
Mike Frysinger | 51f0d52 | 2015-11-21 00:11:17 +0000 | [diff] [blame] | 62 | dev-tcltk/tix |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame] | 63 | ) |
| 64 | xml? ( >=dev-libs/expat-2.1 ) |
| 65 | ) |
| 66 | !!<sys-apps/portage-2.1.9" |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 67 | DEPEND="${RDEPEND} |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame] | 68 | virtual/pkgconfig |
| 69 | >=sys-devel/autoconf-2.65 |
| 70 | !sys-devel/gcc[libffi]" |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 71 | RDEPEND+=" !build? ( app-misc/mime-types ) |
| 72 | doc? ( dev-python/python-docs:${SLOT} )" |
Daniel Kurtz | d47b292 | 2017-07-17 17:47:39 +0800 | [diff] [blame] | 73 | PDEPEND="app-eselect/eselect-python |
Mike Frysinger | 51f0d52 | 2015-11-21 00:11:17 +0000 | [diff] [blame] | 74 | app-admin/python-updater" |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 75 | |
| 76 | S="${WORKDIR}/${MY_P}" |
| 77 | |
| 78 | pkg_setup() { |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 79 | if use berkdb; then |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame] | 80 | 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 Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 84 | else |
| 85 | if has_version "=${CATEGORY}/${PN}-${PV%%.*}*[berkdb]"; then |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame] | 86 | ewarn "You are migrating from =${CATEGORY}/${PN}-${PV%%.*}*[berkdb]" |
| 87 | ewarn "to =${CATEGORY}/${PN}-${PV%%.*}*[-berkdb]." |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 88 | ewarn "You might need to migrate your databases." |
| 89 | fi |
| 90 | fi |
| 91 | } |
| 92 | |
| 93 | src_prepare() { |
Tim Zwiebel | ab07eb2 | 2017-06-03 03:19:57 -0700 | [diff] [blame] | 94 | # 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 Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 99 | # Ensure that internal copies of expat, libffi and zlib are not used. |
Mike Frysinger | 51f0d52 | 2015-11-21 00:11:17 +0000 | [diff] [blame] | 100 | rm -r Modules/expat || die |
| 101 | rm -r Modules/_ctypes/libffi* || die |
| 102 | rm -r Modules/zlib || die |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 103 | |
Mike Frysinger | 51f0d52 | 2015-11-21 00:11:17 +0000 | [diff] [blame] | 104 | if tc-is-cross-compiler; then |
| 105 | local EPATCH_EXCLUDE="*_regenerate_platform-specific_modules.patch" |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 106 | fi |
| 107 | |
Mike Frysinger | 51f0d52 | 2015-11-21 00:11:17 +0000 | [diff] [blame] | 108 | EPATCH_SUFFIX="patch" epatch "${WORKDIR}/patches" |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 109 | |
| 110 | # |
| 111 | # START: ChromiumOS specific changes |
| 112 | # |
| 113 | if tc-is-cross-compiler ; then |
Mike Frysinger | 51f0d52 | 2015-11-21 00:11:17 +0000 | [diff] [blame] | 114 | epatch "${FILESDIR}"/python-2.7.10-cross-h2py.patch |
| 115 | epatch "${FILESDIR}"/python-2.7.10-cross-hack-compiler.patch |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 116 | sed -i 's:^python$EXE:${HOSTPYTHON}:' Lib/*/regen || die |
| 117 | fi |
Mike Frysinger | 51f0d52 | 2015-11-21 00:11:17 +0000 | [diff] [blame] | 118 | epatch "${FILESDIR}"/python-2.7.10-cross-setup-sysroot.patch |
| 119 | epatch "${FILESDIR}"/python-2.7.10-cross-distutils.patch |
Paul Hobbs | 43d07e6 | 2015-05-14 16:43:16 -0700 | [diff] [blame] | 120 | epatch "${FILESDIR}"/python-2.7.3-unique-semaphore-name.patch |
Mike Frysinger | 51f0d52 | 2015-11-21 00:11:17 +0000 | [diff] [blame] | 121 | epatch "${FILESDIR}"/python-2.7.10-ldshared.patch |
Yunlian Jiang | 871d007 | 2018-07-24 11:11:01 -0700 | [diff] [blame] | 122 | epatch "${FILESDIR}"/2.7-disable-nis.patch |
Mike Frysinger | eb04796 | 2014-04-06 10:08:56 -0400 | [diff] [blame] | 123 | # Undo the @libdir@ change for portage's pym folder as it is always |
| 124 | # installed into /usr/lib/ and not the abi libdir. |
| 125 | sed -i \ |
| 126 | -e '/portage.*pym/s:@@GENTOO_LIBDIR@@:lib:g' \ |
| 127 | Lib/site.py || die |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 128 | |
| 129 | sed -i -e "s:sys.exec_prefix]:sys.exec_prefix, '/usr/local']:g" \ |
| 130 | Lib/site.py || die "sed failed to add /usr/local to prefixes" |
| 131 | # |
| 132 | # END: ChromiumOS specific changes |
| 133 | # |
| 134 | |
Mike Frysinger | 51f0d52 | 2015-11-21 00:11:17 +0000 | [diff] [blame] | 135 | # Fix for cross-compiling. |
| 136 | epatch "${FILESDIR}/python-2.7.5-nonfatal-compileall.patch" |
| 137 | epatch "${FILESDIR}/python-2.7.9-ncurses-pkg-config.patch" |
| 138 | |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 139 | sed -i -e "s:@@GENTOO_LIBDIR@@:$(get_libdir):g" \ |
| 140 | Lib/distutils/command/install.py \ |
| 141 | Lib/distutils/sysconfig.py \ |
| 142 | Lib/site.py \ |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame] | 143 | Lib/sysconfig.py \ |
| 144 | Lib/test/test_site.py \ |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 145 | Makefile.pre.in \ |
| 146 | Modules/Setup.dist \ |
| 147 | Modules/getpath.c \ |
| 148 | setup.py || die "sed failed to replace @@GENTOO_LIBDIR@@" |
| 149 | |
Mike Frysinger | 51f0d52 | 2015-11-21 00:11:17 +0000 | [diff] [blame] | 150 | epatch_user |
| 151 | |
| 152 | eautoreconf |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 153 | } |
| 154 | |
| 155 | src_configure() { |
| 156 | if use build; then |
| 157 | # Disable extraneous modules with extra dependencies. |
| 158 | export PYTHON_DISABLE_MODULES="dbm _bsddb gdbm _curses _curses_panel readline _sqlite3 _tkinter _elementtree pyexpat" |
| 159 | export PYTHON_DISABLE_SSL="1" |
| 160 | else |
| 161 | # dbm module can be linked against berkdb or gdbm. |
| 162 | # Defaults to gdbm when both are enabled, #204343. |
| 163 | local disable |
| 164 | use berkdb || use gdbm || disable+=" dbm" |
| 165 | use berkdb || disable+=" _bsddb" |
| 166 | use gdbm || disable+=" gdbm" |
| 167 | use ncurses || disable+=" _curses _curses_panel" |
| 168 | use readline || disable+=" readline" |
| 169 | use sqlite || disable+=" _sqlite3" |
| 170 | use ssl || export PYTHON_DISABLE_SSL="1" |
| 171 | use tk || disable+=" _tkinter" |
| 172 | use xml || disable+=" _elementtree pyexpat" # _elementtree uses pyexpat. |
| 173 | export PYTHON_DISABLE_MODULES="${disable}" |
| 174 | |
| 175 | if ! use xml; then |
| 176 | ewarn "You have configured Python without XML support." |
| 177 | ewarn "This is NOT a recommended configuration as you" |
| 178 | ewarn "may face problems parsing any XML documents." |
| 179 | fi |
| 180 | fi |
| 181 | |
| 182 | if [[ -n "${PYTHON_DISABLE_MODULES}" ]]; then |
| 183 | einfo "Disabled modules: ${PYTHON_DISABLE_MODULES}" |
| 184 | fi |
| 185 | |
| 186 | if [[ "$(gcc-major-version)" -ge 4 ]]; then |
| 187 | append-flags -fwrapv |
| 188 | fi |
| 189 | |
| 190 | filter-flags -malign-double |
| 191 | |
| 192 | [[ "${ARCH}" == "alpha" ]] && append-flags -fPIC |
| 193 | |
| 194 | # https://bugs.gentoo.org/show_bug.cgi?id=50309 |
| 195 | if is-flagq -O3; then |
| 196 | is-flagq -fstack-protector-all && replace-flags -O3 -O2 |
| 197 | use hardened && replace-flags -O3 -O2 |
| 198 | fi |
| 199 | |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 200 | if tc-is-cross-compiler; then |
Mike Frysinger | 51f0d52 | 2015-11-21 00:11:17 +0000 | [diff] [blame] | 201 | # Force some tests that try to poke fs paths. |
| 202 | export ac_cv_file__dev_ptc=no |
| 203 | export ac_cv_file__dev_ptmx=yes |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 204 | fi |
| 205 | |
| 206 | # Export CXX so it ends up in /usr/lib/python2.X/config/Makefile. |
| 207 | tc-export CXX |
| 208 | # The configure script fails to use pkg-config correctly. |
| 209 | # http://bugs.python.org/issue15506 |
| 210 | export ac_cv_path_PKG_CONFIG=$(tc-getPKG_CONFIG) |
| 211 | |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame] | 212 | # Set LDFLAGS so we link modules with -lpython2.7 correctly. |
| 213 | # Needed on FreeBSD unless Python 2.7 is already installed. |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 214 | # Please query BSD team before removing this! |
| 215 | append-ldflags "-L." |
| 216 | |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame] | 217 | local dbmliborder |
| 218 | if use gdbm; then |
| 219 | dbmliborder+="${dbmliborder:+:}gdbm" |
| 220 | fi |
| 221 | if use berkdb; then |
| 222 | dbmliborder+="${dbmliborder:+:}bdb" |
| 223 | fi |
| 224 | |
Mike Frysinger | 51f0d52 | 2015-11-21 00:11:17 +0000 | [diff] [blame] | 225 | BUILD_DIR="${WORKDIR}/${CHOST}" |
| 226 | mkdir -p "${BUILD_DIR}" || die |
| 227 | cd "${BUILD_DIR}" || die |
| 228 | |
| 229 | ECONF_SOURCE="${S}" OPT="" \ |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 230 | econf \ |
| 231 | --with-fpectl \ |
| 232 | --enable-shared \ |
| 233 | $(use_enable ipv6) \ |
| 234 | $(use_with threads) \ |
| 235 | $(use wide-unicode && echo "--enable-unicode=ucs4" || echo "--enable-unicode=ucs2") \ |
| 236 | --infodir='${prefix}/share/info' \ |
| 237 | --mandir='${prefix}/share/man' \ |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame] | 238 | --with-dbmliborder="${dbmliborder}" \ |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 239 | --with-libc="" \ |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame] | 240 | --enable-loadable-sqlite-extensions \ |
| 241 | --with-system-expat \ |
Mike Frysinger | 51f0d52 | 2015-11-21 00:11:17 +0000 | [diff] [blame] | 242 | --with-system-ffi \ |
| 243 | --without-ensurepip |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 244 | |
Mike Frysinger | 51f0d52 | 2015-11-21 00:11:17 +0000 | [diff] [blame] | 245 | if use threads && grep -q "#define POSIX_SEMAPHORES_NOT_ENABLED 1" pyconfig.h; then |
| 246 | eerror "configure has detected that the sem_open function is broken." |
| 247 | eerror "Please ensure that /dev/shm is mounted as a tmpfs with mode 1777." |
| 248 | die "Broken sem_open function (bug 496328)" |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 249 | fi |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 250 | } |
| 251 | |
| 252 | src_compile() { |
Mike Frysinger | 51f0d52 | 2015-11-21 00:11:17 +0000 | [diff] [blame] | 253 | # Avoid invoking pgen for cross-compiles. |
| 254 | touch Include/graminit.h Python/graminit.c |
| 255 | |
| 256 | cd "${BUILD_DIR}" || die |
| 257 | emake |
| 258 | |
| 259 | # Work around bug 329499. See also bug 413751 and 457194. |
| 260 | if has_version dev-libs/libffi[pax_kernel]; then |
| 261 | pax-mark E python |
| 262 | else |
| 263 | pax-mark m python |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 264 | fi |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 265 | } |
| 266 | |
| 267 | src_test() { |
| 268 | # Tests will not work when cross compiling. |
| 269 | if tc-is-cross-compiler; then |
| 270 | elog "Disabling tests due to crosscompiling." |
| 271 | return |
| 272 | fi |
| 273 | |
Mike Frysinger | 51f0d52 | 2015-11-21 00:11:17 +0000 | [diff] [blame] | 274 | cd "${BUILD_DIR}" || die |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 275 | |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 276 | # Skip failing tests. |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame] | 277 | local skipped_tests="distutils gdb" |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 278 | |
| 279 | for test in ${skipped_tests}; do |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame] | 280 | mv "${S}"/Lib/test/test_${test}.py "${T}" |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 281 | done |
| 282 | |
| 283 | # Rerun failed tests in verbose mode (regrtest -w). |
| 284 | emake test EXTRATESTOPTS="-w" < /dev/tty |
| 285 | local result="$?" |
| 286 | |
| 287 | for test in ${skipped_tests}; do |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame] | 288 | mv "${T}/test_${test}.py" "${S}"/Lib/test |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 289 | done |
| 290 | |
| 291 | elog "The following tests have been skipped:" |
| 292 | for test in ${skipped_tests}; do |
| 293 | elog "test_${test}.py" |
| 294 | done |
| 295 | |
| 296 | elog "If you would like to run them, you may:" |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame] | 297 | elog "cd '${EPREFIX}/usr/$(get_libdir)/python${SLOT}/test'" |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 298 | elog "and run the tests separately." |
| 299 | |
| 300 | python_disable_pyc |
| 301 | |
| 302 | if [[ "${result}" -ne 0 ]]; then |
| 303 | die "emake test failed" |
| 304 | fi |
| 305 | } |
| 306 | |
| 307 | src_install() { |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame] | 308 | local libdir=${ED}/usr/$(get_libdir)/python${SLOT} |
| 309 | |
Mike Frysinger | 51f0d52 | 2015-11-21 00:11:17 +0000 | [diff] [blame] | 310 | cd "${BUILD_DIR}" || die |
| 311 | emake DESTDIR="${D}" altinstall |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 312 | |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame] | 313 | sed -e "s/\(LDFLAGS=\).*/\1/" -i "${libdir}/config/Makefile" || die "sed failed" |
| 314 | |
| 315 | # Backwards compat with Gentoo divergence. |
Mike Frysinger | 51f0d52 | 2015-11-21 00:11:17 +0000 | [diff] [blame] | 316 | dosym python${SLOT}-config /usr/bin/python-config-${SLOT} |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 317 | |
| 318 | # Fix collisions between different slots of Python. |
| 319 | mv "${ED}usr/bin/2to3" "${ED}usr/bin/2to3-${SLOT}" |
| 320 | mv "${ED}usr/bin/pydoc" "${ED}usr/bin/pydoc${SLOT}" |
| 321 | mv "${ED}usr/bin/idle" "${ED}usr/bin/idle${SLOT}" |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 322 | rm -f "${ED}usr/bin/smtpd.py" |
| 323 | |
| 324 | if use build; then |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame] | 325 | 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] | 326 | else |
Mike Frysinger | 51f0d52 | 2015-11-21 00:11:17 +0000 | [diff] [blame] | 327 | use berkdb || rm -r "${libdir}/"{bsddb,dbhash.py,test/test_bsddb*} || die |
| 328 | use sqlite || rm -r "${libdir}/"{sqlite3,test/test_sqlite*} || die |
| 329 | use tk || rm -r "${ED}usr/bin/idle${SLOT}" "${libdir}/"{idlelib,lib-tk} || die |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame] | 330 | use elibc_uclibc && rm -fr "${libdir}/"{bsddb/test,test} |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 331 | fi |
| 332 | |
Mike Frysinger | 51f0d52 | 2015-11-21 00:11:17 +0000 | [diff] [blame] | 333 | use threads || rm -r "${libdir}/multiprocessing" || die |
| 334 | use wininst || rm -r "${libdir}/distutils/command/"wininst-*.exe || die |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 335 | |
Mike Frysinger | 51f0d52 | 2015-11-21 00:11:17 +0000 | [diff] [blame] | 336 | dodoc "${S}"/Misc/{ACKS,HISTORY,NEWS} |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 337 | |
| 338 | if use examples; then |
| 339 | insinto /usr/share/doc/${PF}/examples |
Mike Frysinger | 51f0d52 | 2015-11-21 00:11:17 +0000 | [diff] [blame] | 340 | doins -r "${S}"/Tools |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 341 | fi |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame] | 342 | insinto /usr/share/gdb/auto-load/usr/$(get_libdir) #443510 |
| 343 | local libname=$(printf 'e:\n\t@echo $(INSTSONAME)\ninclude Makefile\n' | \ |
| 344 | emake --no-print-directory -s -f - 2>/dev/null) |
| 345 | newins "${S}"/Tools/gdb/libpython.py "${libname}"-gdb.py |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 346 | |
Mike Frysinger | 51f0d52 | 2015-11-21 00:11:17 +0000 | [diff] [blame] | 347 | newconfd "${FILESDIR}/pydoc.conf" pydoc-${SLOT} |
| 348 | newinitd "${FILESDIR}/pydoc.init" pydoc-${SLOT} |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 349 | sed \ |
| 350 | -e "s:@PYDOC_PORT_VARIABLE@:PYDOC${SLOT/./_}_PORT:" \ |
| 351 | -e "s:@PYDOC@:pydoc${SLOT}:" \ |
| 352 | -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] | 353 | |
| 354 | # for python-exec |
| 355 | python_export python${SLOT} EPYTHON PYTHON PYTHON_SITEDIR |
| 356 | |
| 357 | # if not using a cross-compiler, use the fresh binary |
| 358 | if ! tc-is-cross-compiler; then |
Mike Frysinger | 51f0d52 | 2015-11-21 00:11:17 +0000 | [diff] [blame] | 359 | local PYTHON=./python |
| 360 | local -x LD_LIBRARY_PATH=${LD_LIBRARY_PATH+${LD_LIBRARY_PATH}:}. |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame] | 361 | fi |
| 362 | |
| 363 | echo "EPYTHON='${EPYTHON}'" > epython.py |
| 364 | python_domodule epython.py |
| 365 | |
| 366 | # The sysconfig module will actually read the pyconfig.h at runtime to see what kind |
| 367 | # of functionality is enabled in the build. Deploy it behind the back of portage as |
| 368 | # need be. |
Mike Frysinger | d7685db | 2013-04-06 02:03:53 -0400 | [diff] [blame] | 369 | ln "${ED}/usr/include/python${SLOT}/pyconfig.h" "${libdir}/pyconfig_h" || die |
| 370 | |
| 371 | # Workaround https://bugs.gentoo.org/380569 |
| 372 | keepdir /etc/env.d/python |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 373 | } |
| 374 | |
| 375 | pkg_preinst() { |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame] | 376 | 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] | 377 | python_updater_warning="1" |
| 378 | fi |
| 379 | } |
| 380 | |
| 381 | eselect_python_update() { |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 382 | if [[ -z "$(eselect python show)" || ! -f "${EROOT}usr/bin/$(eselect python show)" ]]; then |
| 383 | eselect python update |
| 384 | fi |
| 385 | |
| 386 | if [[ -z "$(eselect python show --python${PV%%.*})" || ! -f "${EROOT}usr/bin/$(eselect python show --python${PV%%.*})" ]]; then |
| 387 | eselect python update --python${PV%%.*} |
| 388 | fi |
| 389 | } |
| 390 | |
| 391 | pkg_postinst() { |
| 392 | eselect_python_update |
| 393 | |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 394 | if [[ "${python_updater_warning}" == "1" ]]; then |
| 395 | ewarn "You have just upgraded from an older version of Python." |
| 396 | ewarn "You should switch active version of Python ${PV%%.*} and run" |
| 397 | ewarn "'python-updater [options]' to rebuild Python modules." |
| 398 | fi |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame] | 399 | |
Mike Frysinger | d7685db | 2013-04-06 02:03:53 -0400 | [diff] [blame] | 400 | local pyconfig="${EROOT}/usr/$(get_libdir)/python${SLOT}/pyconfig_h" |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame] | 401 | if [[ ! -e ${EROOT}/usr/include/python${SLOT}/pyconfig.h ]] ; then |
| 402 | # See pkg_preinst above for details. |
Mike Frysinger | d7685db | 2013-04-06 02:03:53 -0400 | [diff] [blame] | 403 | install -D -m644 "${pyconfig}" "${EROOT}/usr/include/python${SLOT}/pyconfig.h" || die |
Mike Frysinger | 4cfb44a | 2013-03-18 22:37:33 -0400 | [diff] [blame] | 404 | fi |
Mike Frysinger | d7685db | 2013-04-06 02:03:53 -0400 | [diff] [blame] | 405 | rm "${pyconfig}" || die |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 406 | } |
| 407 | |
| 408 | pkg_postrm() { |
| 409 | eselect_python_update |
Mike Frysinger | 682d065 | 2012-07-30 11:38:25 -0400 | [diff] [blame] | 410 | } |