From ea1d100da4d130d0493025cfebf6f56905f6a837 Mon Sep 17 00:00:00 2001 From: Michał Górny Date: Sun, 5 Jun 2016 08:48:13 +0200 Subject: dev-lang/python: Fix distutils to compile .opt-1 & .opt-2 in 3.5 --- .../files/python-3.5-distutils-OO-build.patch | 80 +++++ dev-lang/python/python-3.5.1-r3.ebuild | 360 +++++++++++++++++++++ 2 files changed, 440 insertions(+) create mode 100644 dev-lang/python/files/python-3.5-distutils-OO-build.patch create mode 100644 dev-lang/python/python-3.5.1-r3.ebuild (limited to 'dev-lang/python') diff --git a/dev-lang/python/files/python-3.5-distutils-OO-build.patch b/dev-lang/python/files/python-3.5-distutils-OO-build.patch new file mode 100644 index 000000000000..8af8c30c76fe --- /dev/null +++ b/dev-lang/python/files/python-3.5-distutils-OO-build.patch @@ -0,0 +1,80 @@ +From 90507018442f9adabb586fd3d0a0206b9c2f2f50 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= +Date: Sun, 5 Jun 2016 08:18:01 +0200 +Subject: [PATCH] distutils: make -OO enable both opt-1 and opt-2 optimization + +Bug: http://bugs.python.org/issue27226 +Bug: https://bugs.gentoo.org/585060 +--- + Lib/distutils/command/build_py.py | 8 ++++---- + Lib/distutils/command/install_lib.py | 12 ++++++------ + 2 files changed, 10 insertions(+), 10 deletions(-) + +diff --git a/Lib/distutils/command/build_py.py b/Lib/distutils/command/build_py.py +index cf0ca57..838d4e4 100644 +--- a/Lib/distutils/command/build_py.py ++++ b/Lib/distutils/command/build_py.py +@@ -315,9 +315,9 @@ class build_py (Command): + if self.compile: + outputs.append(importlib.util.cache_from_source( + filename, optimization='')) +- if self.optimize > 0: ++ for opt in range(1, self.optimize + 1): + outputs.append(importlib.util.cache_from_source( +- filename, optimization=self.optimize)) ++ filename, optimization=opt)) + + outputs += [ + os.path.join(build_dir, filename) +@@ -387,8 +387,8 @@ class build_py (Command): + if self.compile: + byte_compile(files, optimize=0, + force=self.force, prefix=prefix, dry_run=self.dry_run) +- if self.optimize > 0: +- byte_compile(files, optimize=self.optimize, ++ for opt in range(1, self.optimize + 1): ++ byte_compile(files, optimize=opt, + force=self.force, prefix=prefix, dry_run=self.dry_run) + + class build_py_2to3(build_py, Mixin2to3): +diff --git a/Lib/distutils/command/install_lib.py b/Lib/distutils/command/install_lib.py +index 6154cf0..049b662 100644 +--- a/Lib/distutils/command/install_lib.py ++++ b/Lib/distutils/command/install_lib.py +@@ -24,8 +24,8 @@ class install_lib(Command): + # 2) compile .pyc only (--compile --no-optimize; default) + # 3) compile .pyc and "opt-1" .pyc (--compile --optimize) + # 4) compile "opt-1" .pyc only (--no-compile --optimize) +- # 5) compile .pyc and "opt-2" .pyc (--compile --optimize-more) +- # 6) compile "opt-2" .pyc only (--no-compile --optimize-more) ++ # 5) compile .pyc, "opt-1" and "opt-2" .pyc (--compile --optimize-more) ++ # 6) compile "opt-1" and "opt-2" .pyc (--no-compile --optimize-more) + # + # The UI for this is two options, 'compile' and 'optimize'. + # 'compile' is strictly boolean, and only decides whether to +@@ -132,8 +132,8 @@ class install_lib(Command): + byte_compile(files, optimize=0, + force=self.force, prefix=install_root, + dry_run=self.dry_run) +- if self.optimize > 0: +- byte_compile(files, optimize=self.optimize, ++ for opt in range(1, self.optimize + 1): ++ byte_compile(files, optimize=opt, + force=self.force, prefix=install_root, + verbose=self.verbose, dry_run=self.dry_run) + +@@ -167,9 +167,9 @@ class install_lib(Command): + if self.compile: + bytecode_files.append(importlib.util.cache_from_source( + py_file, optimization='')) +- if self.optimize > 0: ++ for opt in range(1, self.optimize + 1): + bytecode_files.append(importlib.util.cache_from_source( +- py_file, optimization=self.optimize)) ++ py_file, optimization=opt)) + + return bytecode_files + +-- +2.8.3 + diff --git a/dev-lang/python/python-3.5.1-r3.ebuild b/dev-lang/python/python-3.5.1-r3.ebuild new file mode 100644 index 000000000000..3e8fc9839166 --- /dev/null +++ b/dev-lang/python/python-3.5.1-r3.ebuild @@ -0,0 +1,360 @@ +# Copyright 1999-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +EAPI="5" +WANT_LIBTOOL="none" + +inherit autotools eutils flag-o-matic multilib pax-utils python-utils-r1 toolchain-funcs + +MY_P="Python-${PV/_/}" +PATCHSET_VERSION="3.5.1-0" + +DESCRIPTION="An interpreted, interactive, object-oriented programming language" +HOMEPAGE="http://www.python.org/" +SRC_URI="http://www.python.org/ftp/python/${PV%_rc*}/${MY_P}.tar.xz + https://dev.gentoo.org/~floppym/python/python-gentoo-patches-${PATCHSET_VERSION}.tar.xz" + +LICENSE="PSF-2" +SLOT="3.5/3.5m" +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd" +IUSE="build elibc_uclibc examples gdbm hardened ipv6 libressl +ncurses +readline sqlite +ssl +threads tk wininst +xml" + +# Do not add a dependency on dev-lang/python to this ebuild. +# If you need to apply a patch which requires python for bootstrapping, please +# run the bootstrap code on your dev box and include the results in the +# patchset. See bug 447752. + +RDEPEND="app-arch/bzip2:0= + app-arch/xz-utils:0= + >=sys-libs/zlib-1.1.3:0= + virtual/libffi + virtual/libintl + gdbm? ( sys-libs/gdbm:0=[berkdb] ) + ncurses? ( + >=sys-libs/ncurses-5.2:0= + readline? ( >=sys-libs/readline-4.1:0= ) + ) + sqlite? ( >=dev-db/sqlite-3.3.8:3= ) + ssl? ( + !libressl? ( dev-libs/openssl:0= ) + libressl? ( dev-libs/libressl:= ) + ) + tk? ( + >=dev-lang/tcl-8.0:0= + >=dev-lang/tk-8.0:0= + dev-tcltk/blt:0= + dev-tcltk/tix + ) + xml? ( >=dev-libs/expat-2.1:0= ) + !!/dev/null) + newins "${S}"/Tools/gdb/libpython.py "${libname}"-gdb.py + + newconfd "${FILESDIR}/pydoc.conf" pydoc-${PYVER} + newinitd "${FILESDIR}/pydoc.init" pydoc-${PYVER} + sed \ + -e "s:@PYDOC_PORT_VARIABLE@:PYDOC${PYVER/./_}_PORT:" \ + -e "s:@PYDOC@:pydoc${PYVER}:" \ + -i "${ED}etc/conf.d/pydoc-${PYVER}" "${ED}etc/init.d/pydoc-${PYVER}" || die "sed failed" + + # for python-exec + local vars=( EPYTHON PYTHON_SITEDIR PYTHON_SCRIPTDIR ) + + # if not using a cross-compiler, use the fresh binary + if ! tc-is-cross-compiler; then + local -x PYTHON=./python + local -x LD_LIBRARY_PATH=${LD_LIBRARY_PATH+${LD_LIBRARY_PATH}:}. + else + vars=( PYTHON "${vars[@]}" ) + fi + + python_export "python${PYVER}" "${vars[@]}" + echo "EPYTHON='${EPYTHON}'" > epython.py || die + python_domodule epython.py + + # python-exec wrapping support + local pymajor=${PYVER%.*} + mkdir -p "${D}${PYTHON_SCRIPTDIR}" || die + # python and pythonX + ln -s "../../../bin/${abiver}" \ + "${D}${PYTHON_SCRIPTDIR}/python${pymajor}" || die + ln -s "python${pymajor}" \ + "${D}${PYTHON_SCRIPTDIR}/python" || die + # python-config and pythonX-config + # note: we need to create a wrapper rather than symlinking it due + # to some random dirname(argv[0]) magic performed by python-config + cat > "${D}${PYTHON_SCRIPTDIR}/python${pymajor}-config" <<-EOF || die + #!/bin/sh + exec "${abiver}-config" "\${@}" + EOF + chmod +x "${D}${PYTHON_SCRIPTDIR}/python${pymajor}-config" || die + ln -s "python${pymajor}-config" \ + "${D}${PYTHON_SCRIPTDIR}/python-config" || die + # 2to3, pydoc, pyvenv + ln -s "../../../bin/2to3-${PYVER}" \ + "${D}${PYTHON_SCRIPTDIR}/2to3" || die + ln -s "../../../bin/pydoc${PYVER}" \ + "${D}${PYTHON_SCRIPTDIR}/pydoc" || die + ln -s "../../../bin/pyvenv-${PYVER}" \ + "${D}${PYTHON_SCRIPTDIR}/pyvenv" || die + # idle + if use tk; then + ln -s "../../../bin/idle${PYVER}" \ + "${D}${PYTHON_SCRIPTDIR}/idle" || die + fi +} + +pkg_preinst() { + if has_version "<${CATEGORY}/${PN}-${PYVER}" && ! has_version ">=${CATEGORY}/${PN}-${PYVER}_alpha"; then + python_updater_warning="1" + fi +} + +eselect_python_update() { + if [[ -z "$(eselect python show)" || ! -f "${EROOT}usr/bin/$(eselect python show)" ]]; then + eselect python update + fi + + if [[ -z "$(eselect python show --python${PV%%.*})" || ! -f "${EROOT}usr/bin/$(eselect python show --python${PV%%.*})" ]]; then + eselect python update --python${PV%%.*} + fi +} + +pkg_postinst() { + eselect_python_update + + if [[ "${python_updater_warning}" == "1" ]]; then + ewarn "You have just upgraded from an older version of Python." + ewarn + ewarn "Please adjust PYTHON_TARGETS (if so desired), and run emerge with the --newuse or --changed-use option to rebuild packages installing python modules." + fi +} + +pkg_postrm() { + eselect_python_update +} -- cgit v1.2.3-65-gdbad