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