[dev-lang/python] add gdbm-1.9 patch, fixes bug 3159

This commit is contained in:
Fabio Erculiani
2012-04-10 13:07:18 +02:00
parent 3d147cb86a
commit 4bb3dae245
13 changed files with 755 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
AUX linux2.patch 332 RMD160 b6c4f45baee17fc5b0a88b63bbca87b77eaa16d3 SHA1 7722cc338a88d690e06f2ed0d9257b086286c288 SHA256 8c5f8d73e279767190c9567f959514167101ea2648f9f4c8146704c5946d8b41
AUX pydoc.conf 279 RMD160 85dcc3abd24faf09f3753b5c2299517f9b2ebc6a SHA1 c1faef486a0041c2175bfbc2cf10eccaa574e8c2 SHA256 6437e85d16d34efaf2665b3cabb0707392e6dee3df04989d3fcac63fd22997e8
AUX pydoc.init 741 RMD160 f6414ad95d7f1258f34afa5c9ff5efaa508a4d9d SHA1 576b5e7ac3c7e36d2e809de5b419d87f1bf23aba SHA256 913be80dea585dd161d2fd439f56a358f148853d8305cb0dbf113c91eb1643f5
AUX python-2.4.4-test-cross.patch 977 RMD160 8fdcd45dc202993988f7a1c2b3d918068883b99e SHA1 96f25777150ba05765282a43f08da6b6fab3cb73 SHA256 ff2a131776d560d188ec5069e17fea3eb09c26fdd02124ae5ff34d791c9fd9f6
AUX python-2.5-cross-printf.patch 903 RMD160 8dc0ee148120aaf7667624bdb5574bb6af5d2a00 SHA1 596e05be8cde43e4cdd87c8ed06ebb40828f7cea SHA256 1e91e5123d74d89aa8fc9dc60d98516b785f851e43da9b634ae535130e24e780
AUX python-2.6-chflags-cross.patch 1716 RMD160 b0ec772a41a24d51f4c7430b19bcc6251cd6be87 SHA1 4745cd53cef503c41c50573ad97f40eb89fd4bcd SHA256 7c36689db47720052069725036983c2fb6959f425e3777aae55976b2788d463f
AUX python-2.6-test-cross.patch 914 RMD160 1f421b5565d39a24b887e85cbecaf3857741f756 SHA1 9c05fbe28aac6373f24317db5c277bc4549dde0c SHA256 8264f6ffe5aedcce67bea00b0346e5416a5486da2229bf82fe748d87ec65c4de
AUX python-2.7-gdbm-1.9.patch 291 RMD160 1d360511509655f804f5d21e1455e62d6f25eac7 SHA1 0e24badfef8e5659ed61fc3483b87f4dfc3be393 SHA256 33e66b84265031a088e371d5ab22f396437929d64f6d4bff400c6fefea5f1320
AUX python-3-distutils-egg-utf8.patch 1636 RMD160 840d7fea399df295cbba1124fb8fcb797a7011ed SHA1 4697d7d737101ad3f1d9c4a0c6ff848fd7114823 SHA256 81d66620f0774aa2fb6c9664670862eb1b666ba15874b5498af28360f2e1aa52
AUX python-3.2-soname_typo.patch 1724 RMD160 1b112382152731768b655279145c7caa31d1094f SHA1 808fdab3b1d1664fc20c67dce008e7ea48134a4e SHA256 776366c3cc67c7d66883846acee8cc1b795c25f6e35e927793be8c54162491e2
AUX python-config-2.4-r1 1624 RMD160 e4e6893c9e8414289c0c70c0f4be58835911e376 SHA1 addf9a6eb81e636364264a6abb3d96f01ea0cf90 SHA256 923a9e896f99cca5aa4ccbb02f981c6e26a2b1aa42326de2359d3c884bde2a9f
DIST Python-2.7.2.tar.bz2 11754834 RMD160 c3bf4f09b7c429a4d9f4cc251c795304cd5232c5 SHA1 417bdeea77abfaf1b9257fc6b4a04aaa209f4547 SHA256 5057eb067eb5b5a6040dbd0e889e06550bde9ec041dadaa855ee9490034cbdab
DIST python-gentoo-patches-2.7.2.tar.bz2 14485 RMD160 6b66705d61b525d0089326ddb700ad3c5ad6e23e SHA1 94fc9b00cc7e7c60cce41640dc09fd2395a5c5d9 SHA256 29616ce50244c0f7c85b903dcb939d656bfd9d5e8a930d90bff6cf878f3ac5a5
EBUILD python-2.7.2-r3.ebuild 12123 RMD160 6175396fe6cabfb1882650a5c2ab7d13d591c0e0 SHA1 180ccbf5f0ed2e734f07edbfc1cc88576f3a91df SHA256 f8b1f5624393a51df93048508e99c8845e12067fd129c8289cd9bc3f59853f92
+13
View File
@@ -0,0 +1,13 @@
http://hg.python.org/cpython/rev/c816479f6aaf/
diff --git a/configure.in b/configure.in
--- a/configure.in
+++ b/configure.in
@@ -293,6 +293,7 @@ then
MACHDEP="$ac_md_system$ac_md_release"
case $MACHDEP in
+ linux*) MACHDEP="linux2";;
cygwin*) MACHDEP="cygwin";;
darwin*) MACHDEP="darwin";;
atheos*) MACHDEP="atheos";;
+7
View File
@@ -0,0 +1,7 @@
# /etc/init.d/pydoc.conf
# $Header: /var/cvsroot/gentoo-x86/dev-lang/python/files/pydoc.conf,v 1.3 2011/10/27 13:56:55 neurogeek Exp $
# This file contains the configuration for pydoc's internal webserver.
# Default port for Python's pydoc server.
@PYDOC_PORT_VARIABLE@="7464"
+29
View File
@@ -0,0 +1,29 @@
#!/sbin/runscript
# Copyright 1999-2011 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public Licence v2
# $Header: /var/cvsroot/gentoo-x86/dev-lang/python/files/pydoc.init,v 1.4 2011/10/27 13:56:55 neurogeek Exp $
depend() {
need net
}
start() {
local pydoc_port="${@PYDOC_PORT_VARIABLE@-${PYDOC_PORT}}"
if [ -z "${pydoc_port}" ]; then
eerror "Port not set"
return 1
fi
ebegin "Starting pydoc server on port ${pydoc_port}"
start-stop-daemon --start --background --make-pidfile \
--pidfile /var/run/@PYDOC@.pid \
--exec /usr/bin/@PYDOC@ -- -p "${pydoc_port}"
eend $?
}
stop() {
ebegin "Stopping pydoc server"
start-stop-daemon --stop --quiet --pidfile /var/run/@PYDOC@.pid
eend $?
}
@@ -0,0 +1,19 @@
--- Python-2.4.4/Lib/test/test_multibytecodec.py.orig 2007-09-10 14:52:34.424592960 -0400
+++ Python-2.4.4/Lib/test/test_multibytecodec.py 2007-09-10 14:53:30.646201491 -0400
@@ -81,11 +81,11 @@ class Test_ISO2022(unittest.TestCase):
uni = u':hu4:unit\xe9 de famille'
self.assertEqual(iso2022jp2.decode('iso2022-jp-2'), uni)
- def test_iso2022_jp_g0(self):
- self.failIf('\x0e' in u'\N{SOFT HYPHEN}'.encode('iso-2022-jp-2'))
- for encoding in ('iso-2022-jp-2004', 'iso-2022-jp-3'):
- e = u'\u3406'.encode(encoding)
- self.failIf(filter(lambda x: x >= '\x80', e))
+# def test_iso2022_jp_g0(self):
+# self.failIf('\x0e' in u'\N{SOFT HYPHEN}'.encode('iso-2022-jp-2'))
+# for encoding in ('iso-2022-jp-2004', 'iso-2022-jp-3'):
+# e = u'\u3406'.encode(encoding)
+# self.failIf(filter(lambda x: x >= '\x80', e))
def test_bug1572832(self):
if sys.maxunicode >= 0x10000:
@@ -0,0 +1,34 @@
http://bugs.gentoo.org/239110
assume %zd is supported when cross-compiling. any target we care about
supports it, so ...
--- configure.in
+++ configure.in
@@ -3417,7 +3417,7 @@
-AC_MSG_CHECKING(for %zd printf() format support)
+AC_CACHE_CHECK([for %zd printf() format support], [py_cv_has_zd_printf], [dnl
AC_TRY_RUN([#include <stdio.h>
#include <stddef.h>
#include <string.h>
@@ -3451,10 +3451,13 @@
return 1;
return 0;
-}],
-[AC_MSG_RESULT(yes)
- AC_DEFINE(PY_FORMAT_SIZE_T, "z", [Define to printf format modifier for Py_ssize_t])],
- AC_MSG_RESULT(no))
+}], [py_cv_has_zd_printf="yes"],
+ [py_cv_has_zd_printf="no"],
+ [py_cv_has_zd_printf="cross -- assuming yes"]
+)])
+if test "$py_cv_has_zd_printf" != "no" ; then
+ AC_DEFINE(PY_FORMAT_SIZE_T, "z", [Define to printf format modifier for Py_ssize_t])
+fi
AC_CHECK_TYPE(socklen_t,,
AC_DEFINE(socklen_t,int,
@@ -0,0 +1,59 @@
if we're cross-compiling, fall back to a link-only test rather than trying
to run a program for the chflags functions
--- python-2.6/configure.in
+++ python-2.6/configure.in
@@ -2565,7 +2565,7 @@
# On Tru64, chflags seems to be present, but calling it will
# exit Python
-AC_MSG_CHECKING(for chflags)
+AC_CACHE_CHECK([for chflags], [py_cv_has_chflags], [dnl
AC_TRY_RUN([
#include <sys/stat.h>
#include <unistd.h>
@@ -2575,12 +2575,18 @@
return 1;
return 0;
}
-],AC_DEFINE(HAVE_CHFLAGS, 1, Define to 1 if you have the `chflags' function.)
- AC_MSG_RESULT(yes),
- AC_MSG_RESULT(no)
-)
+], [py_cv_has_chflags="yes"],
+ [py_cv_has_chflags="no"],
+ [py_cv_has_chflags="cross"])
+])
+if test "$py_cv_has_chflags" = "cross" ; then
+ AC_CHECK_FUNC([chflags], [py_cv_has_chflags="yes"], [py_cv_has_chflags="no"])
+fi
+if test "$py_cv_has_chflags" = "yes" ; then
+ AC_DEFINE(HAVE_CHFLAGS, 1, Define to 1 if you have the `chflags' function.)
+fi
-AC_MSG_CHECKING(for lchflags)
+AC_CACHE_CHECK([for lchflags], [py_cv_has_lchflags], [dnl
AC_TRY_RUN([
#include <sys/stat.h>
#include <unistd.h>
@@ -2590,10 +2596,16 @@
return 1;
return 0;
}
-],AC_DEFINE(HAVE_LCHFLAGS, 1, Define to 1 if you have the `lchflags' function.)
- AC_MSG_RESULT(yes),
- AC_MSG_RESULT(no)
-)
+], [py_cv_has_lchflags="yes"],
+ [py_cv_has_lchflags="no"],
+ [py_cv_has_lchflags="cross"])
+])
+if test "$py_cv_has_lchflags" = "cross" ; then
+ AC_CHECK_FUNC([lchflags], [py_cv_has_lchflags="yes"], [py_cv_has_lchflags="no"])
+fi
+if test "$py_cv_has_lchflags" = "yes" ; then
+ AC_DEFINE(HAVE_LCHFLAGS, 1, Define to 1 if you have the `lchflags' function.)
+fi
dnl Check if system zlib has *Copy() functions
dnl
@@ -0,0 +1,19 @@
--- Lib/test/test_multibytecodec.py.orig 2008-04-19 18:48:59.000000000 +0300
+++ Lib/test/test_multibytecodec.py 2008-04-19 18:49:44.000000000 +0300
@@ -212,11 +212,11 @@
uni = u':hu4:unit\xe9 de famille'
self.assertEqual(iso2022jp2.decode('iso2022-jp-2'), uni)
- def test_iso2022_jp_g0(self):
- self.failIf('\x0e' in u'\N{SOFT HYPHEN}'.encode('iso-2022-jp-2'))
- for encoding in ('iso-2022-jp-2004', 'iso-2022-jp-3'):
- e = u'\u3406'.encode(encoding)
- self.failIf(filter(lambda x: x >= '\x80', e))
+ #def test_iso2022_jp_g0(self):
+ # self.failIf('\x0e' in u'\N{SOFT HYPHEN}'.encode('iso-2022-jp-2'))
+ # for encoding in ('iso-2022-jp-2004', 'iso-2022-jp-3'):
+ # e = u'\u3406'.encode(encoding)
+ # self.failIf(filter(lambda x: x >= '\x80', e))
def test_bug1572832(self):
if sys.maxunicode >= 0x10000:
@@ -0,0 +1,11 @@
--- a/Lib/whichdb.py
+++ b/Lib/whichdb.py
@@ -91,7 +91,7 @@ def whichdb(filename):
return ""
# Check for GNU dbm
- if magic == 0x13579ace:
+ if magic == (0x13579ace, 0x13579acd, 0x13579acf):
return "gdbm"
# Check for old Berkeley db hash file format v2
@@ -0,0 +1,43 @@
# HG changeset patch
# User Victor Stinner <victor.stinner@haypocalc.com>
# Date 1315259096 -7200
# Node ID fb4d2e6d393e96baac13c4efc216e361bf12c293
# Parent cb47cf5138a4567718a25d69a79d1c62d13f187c
Issue #9561: distutils now reads and writes egg-info files using UTF-8
instead of the locale encoding.
diff --git a/Lib/distutils/command/install_egg_info.py b/Lib/distutils/command/install_egg_info.py
--- a/Lib/distutils/command/install_egg_info.py
+++ b/Lib/distutils/command/install_egg_info.py
@@ -40,9 +40,8 @@ class install_egg_info(Command):
"Creating "+self.install_dir)
log.info("Writing %s", target)
if not self.dry_run:
- f = open(target, 'w')
- self.distribution.metadata.write_pkg_file(f)
- f.close()
+ with open(target, 'w', encoding='UTF-8') as f:
+ self.distribution.metadata.write_pkg_file(f)
def get_outputs(self):
return self.outputs
diff --git a/Lib/distutils/dist.py b/Lib/distutils/dist.py
--- a/Lib/distutils/dist.py
+++ b/Lib/distutils/dist.py
@@ -1010,11 +1010,9 @@ class DistributionMetadata:
def write_pkg_info(self, base_dir):
"""Write the PKG-INFO file into the release tree.
"""
- pkg_info = open(os.path.join(base_dir, 'PKG-INFO'), 'w')
- try:
+ with open(os.path.join(base_dir, 'PKG-INFO'), 'w',
+ encoding='UTF-8') as pkg_info:
self.write_pkg_file(pkg_info)
- finally:
- pkg_info.close()
def write_pkg_file(self, file):
"""Write the PKG-INFO format data to a file object.
@@ -0,0 +1,51 @@
# HG changeset patch
# User Martin v. Löwis <martin@v.loewis.de>
# Date 1304919465 -7200
# Node ID 749686064642118c5ccc8ad28105472321931353
# Parent 4f3f67a595fb05f04d89ed906df911b743e47463
Use --as-needed when linking libpython3.so. Closes #11347.
Patch by Arfrever Frehtes Taifersar Arahesis.
diff --git a/Makefile.pre.in b/Makefile.pre.in
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -76,6 +76,7 @@ PY_CFLAGS= $(BASECFLAGS) $(OPT) $(CONFIG
# environment variables
PY_CPPFLAGS= -I. -IInclude -I$(srcdir)/Include $(CONFIGURE_CPPFLAGS) $(CPPFLAGS)
PY_LDFLAGS= $(CONFIGURE_LDFLAGS) $(LDFLAGS)
+NO_AS_NEEDED= @NO_AS_NEEDED@
LDLAST= @LDLAST@
SGI_ABI= @SGI_ABI@
CCSHARED= @CCSHARED@
@@ -459,7 +460,7 @@ libpython$(LDVERSION).so: $(LIBRARY_OBJS
fi
libpython3.so: libpython$(LDVERSION).so
- $(BLDSHARED) -o $@ -Wl,-hl$@ $^
+ $(BLDSHARED) $(NO_AS_NEEDED) -o $@ -Wl,-h$@ $^
libpython$(LDVERSION).dylib: $(LIBRARY_OBJS)
$(CC) -dynamiclib -Wl,-single_module $(PY_LDFLAGS) -undefined dynamic_lookup -Wl,-install_name,$(prefix)/lib/libpython$(LDVERSION).dylib -Wl,-compatibility_version,$(VERSION) -Wl,-current_version,$(VERSION) -o $@ $(LIBRARY_OBJS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \
diff --git a/configure.in b/configure.in
--- a/configure.in
+++ b/configure.in
@@ -525,6 +525,18 @@ then
fi
+AC_MSG_CHECKING([for -Wl,--no-as-needed])
+save_LDFLAGS="$LDFLAGS"
+LDFLAGS="$LDFLAGS -Wl,--no-as-needed"
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
+ [NO_AS_NEEDED="-Wl,--no-as-needed"
+ AC_MSG_RESULT([yes])],
+ [NO_AS_NEEDED=""
+ AC_MSG_RESULT([no])])
+LDFLAGS="$save_LDFLAGS"
+AC_SUBST(NO_AS_NEEDED)
+
+
# checks for UNIX variants that set C preprocessor variables
AC_USE_SYSTEM_EXTENSIONS
@@ -0,0 +1,58 @@
#! /usr/bin/python2.4
import sys
import os
import getopt
from distutils import sysconfig
valid_opts = ['prefix', 'exec-prefix', 'includes', 'libs', 'cflags',
'ldflags', 'help']
def exit_with_usage(code=1):
print >>sys.stderr, "Usage: %s [%s]" % (sys.argv[0],
'|'.join('--'+opt for opt in valid_opts))
sys.exit(code)
try:
opts, args = getopt.getopt(sys.argv[1:], '', valid_opts)
except getopt.error:
exit_with_usage()
if not opts:
#exit_with_usage()
#be compatible with our old python-config-2.4
import string
print "-lpython2.4 -lm -L/usr/lib/python2.4/config",string.join(string.split(sysconfig.get_config_var("MODLIBS")))
sys.exit(0)
opt = opts[0][0]
pyver = sysconfig.get_config_var('VERSION')
getvar = sysconfig.get_config_var
if opt == '--help':
exit_with_usage(0)
elif opt == '--prefix':
print sysconfig.PREFIX
elif opt == '--exec-prefix':
print sysconfig.EXEC_PREFIX
elif opt in ('--includes', '--cflags'):
flags = ['-I' + sysconfig.get_python_inc(),
'-I' + sysconfig.get_python_inc(plat_specific=True)]
if opt == '--cflags':
flags.extend(getvar('CFLAGS').split())
print ' '.join(flags)
elif opt in ('--libs', '--ldflags'):
libs = getvar('LIBS').split() + getvar('SYSLIBS').split()
libs.append('-lpython'+pyver)
# add the prefix/lib/pythonX.Y/config dir, but only if there is no
# shared library in prefix/lib/.
if opt == '--ldflags' and not getvar('Py_ENABLE_SHARED'):
libs.insert(0, '-L' + getvar('LIBPL'))
print ' '.join(libs)
+398
View File
@@ -0,0 +1,398 @@
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-lang/python/python-2.7.2-r3.ebuild,v 1.11 2012/02/13 18:29:32 xarthisius Exp $
EAPI="2"
WANT_AUTOMAKE="none"
inherit autotools eutils flag-o-matic multilib python toolchain-funcs
if [[ "${PV}" == *_pre* ]]; then
inherit mercurial
EHG_REPO_URI="http://hg.python.org/cpython"
EHG_REVISION=""
else
MY_PV="${PV%_p*}"
MY_P="Python-${MY_PV}"
fi
PATCHSET_REVISION="0"
DESCRIPTION="Python is an interpreted, interactive, object-oriented programming language."
HOMEPAGE="http://www.python.org/"
if [[ "${PV}" == *_pre* ]]; then
SRC_URI=""
else
SRC_URI="http://www.python.org/ftp/python/${MY_PV}/${MY_P}.tar.bz2
mirror://gentoo/python-gentoo-patches-${MY_PV}$([[ "${PATCHSET_REVISION}" != "0" ]] && echo "-r${PATCHSET_REVISION}").tar.bz2"
fi
LICENSE="PSF-2"
SLOT="2.7"
PYTHON_ABI="${SLOT}"
KEYWORDS="alpha amd64 arm hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86 ~sparc-fbsd ~x86-fbsd"
IUSE="-berkdb build doc elibc_uclibc examples gdbm ipv6 +ncurses +readline sqlite +ssl +threads tk +wide-unicode wininst +xml"
RDEPEND=">=app-admin/eselect-python-20091230
app-arch/bzip2
>=sys-libs/zlib-1.1.3
virtual/libffi
virtual/libintl
!build? (
berkdb? ( || (
sys-libs/db:4.8
sys-libs/db:4.7
sys-libs/db:4.6
sys-libs/db:4.5
sys-libs/db:4.4
sys-libs/db:4.3
sys-libs/db:4.2
) )
gdbm? ( sys-libs/gdbm )
ncurses? (
>=sys-libs/ncurses-5.2
readline? ( >=sys-libs/readline-4.1 )
)
sqlite? ( >=dev-db/sqlite-3.3.8:3[extensions] )
ssl? ( dev-libs/openssl )
tk? (
>=dev-lang/tk-8.0
dev-tcltk/blt
)
xml? ( >=dev-libs/expat-2 )
)
!!<sys-apps/portage-2.1.9"
DEPEND=">=sys-devel/autoconf-2.65
${RDEPEND}
$([[ "${PV}" == *_pre* ]] && echo "=${CATEGORY}/${PN}-${PV%%.*}*")
dev-util/pkgconfig
$([[ "${PV}" =~ ^[[:digit:]]+\.[[:digit:]]+_pre ]] && echo "doc? ( dev-python/sphinx )")
!sys-devel/gcc[libffi]"
RDEPEND+=" !build? ( app-misc/mime-types )
$([[ "${PV}" =~ ^[[:digit:]]+\.[[:digit:]]+_pre ]] || echo "doc? ( dev-python/python-docs:${SLOT} )")"
PDEPEND="app-admin/python-updater"
if [[ "${PV}" != *_pre* ]]; then
S="${WORKDIR}/${MY_P}"
fi
pkg_setup() {
python_pkg_setup
if use berkdb; then
ewarn "\"bsddb\" module is out-of-date and no longer maintained inside dev-lang/python."
ewarn "\"bsddb\" and \"dbhash\" modules have been additionally removed in Python 3."
ewarn "You should use external, still maintained \"bsddb3\" module provided by dev-python/bsddb3,"
ewarn "which supports both Python 2 and Python 3."
else
if has_version "=${CATEGORY}/${PN}-${PV%%.*}*[berkdb]"; then
ewarn "You are migrating from =${CATEGORY}/${PN}-${PV%%.*}*[berkdb] to =${CATEGORY}/${PN}-${PV%%.*}*[-berkdb]."
ewarn "You might need to migrate your databases."
fi
fi
}
src_prepare() {
# Ensure that internal copies of expat, libffi and zlib are not used.
rm -fr Modules/expat
rm -fr Modules/_ctypes/libffi*
rm -fr Modules/zlib
if [[ "${PV}" =~ ^[[:digit:]]+\.[[:digit:]]+_pre ]]; then
if [[ "$(hg branch)" != "default" ]]; then
die "Invalid EHG_REVISION"
fi
fi
if [[ "${PV}" =~ ^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+_pre ]]; then
if [[ "$(hg branch)" != "${SLOT}" ]]; then
die "Invalid EHG_REVISION"
fi
if grep -Eq '#define PY_RELEASE_LEVEL[[:space:]]+PY_RELEASE_LEVEL_FINAL' Include/patchlevel.h; then
# Update micro version, release level and version string.
local micro_version="${PV%_pre*}"
micro_version="${micro_version##*.}"
local version_string="${PV%.*}.$((${micro_version} - 1))+"
sed \
-e "s/\(#define PY_MICRO_VERSION[[:space:]]\+\)[^[:space:]]\+/\1${micro_version}/" \
-e "s/\(#define PY_RELEASE_LEVEL[[:space:]]\+\)[^[:space:]]\+/\1PY_RELEASE_LEVEL_ALPHA/" \
-e "s/\(#define PY_VERSION[[:space:]]\+\"\)[^\"]\+\(\"\)/\1${version_string}\2/" \
-i Include/patchlevel.h || die "sed failed"
fi
fi
local excluded_patches
if ! tc-is-cross-compiler; then
excluded_patches="*_all_crosscompile.patch"
fi
local patchset_dir
if [[ "${PV}" == *_pre* ]]; then
patchset_dir="${FILESDIR}/${SLOT}-${PATCHSET_REVISION}"
else
patchset_dir="${WORKDIR}/${MY_PV}"
fi
EPATCH_EXCLUDE="${excluded_patches}" EPATCH_SUFFIX="patch" epatch "${patchset_dir}"
epatch "${FILESDIR}/linux2.patch"
# Bug 3159, upstream:
# http://hg.python.org/cpython/rev/14cafb8d1480
epatch "${FILESDIR}/${PN}-2.7-gdbm-1.9.patch"
sed -i -e "s:@@GENTOO_LIBDIR@@:$(get_libdir):g" \
Lib/distutils/command/install.py \
Lib/distutils/sysconfig.py \
Lib/site.py \
Lib/sysconfig.py \
Lib/test/test_site.py \
Makefile.pre.in \
Modules/Setup.dist \
Modules/getpath.c \
setup.py || die "sed failed to replace @@GENTOO_LIBDIR@@"
# Linux-3 compat. Bug #374579 (upstream issue12571)
cp -r "${S}/Lib/plat-linux2" "${S}/Lib/plat-linux3" || die
eautoconf
eautoheader
}
src_configure() {
if use build; then
# Disable extraneous modules with extra dependencies.
export PYTHON_DISABLE_MODULES="dbm _bsddb gdbm _curses _curses_panel readline _sqlite3 _tkinter _elementtree pyexpat"
export PYTHON_DISABLE_SSL="1"
else
# dbm module can be linked against berkdb or gdbm.
# Defaults to gdbm when both are enabled, #204343.
local disable
use berkdb || use gdbm || disable+=" dbm"
use berkdb || disable+=" _bsddb"
use gdbm || disable+=" gdbm"
use ncurses || disable+=" _curses _curses_panel"
use readline || disable+=" readline"
use sqlite || disable+=" _sqlite3"
use ssl || export PYTHON_DISABLE_SSL="1"
use tk || disable+=" _tkinter"
use xml || disable+=" _elementtree pyexpat" # _elementtree uses pyexpat.
export PYTHON_DISABLE_MODULES="${disable}"
if ! use xml; then
ewarn "You have configured Python without XML support."
ewarn "This is NOT a recommended configuration as you"
ewarn "may face problems parsing any XML documents."
fi
fi
if [[ -n "${PYTHON_DISABLE_MODULES}" ]]; then
einfo "Disabled modules: ${PYTHON_DISABLE_MODULES}"
fi
if [[ "$(gcc-major-version)" -ge 4 ]]; then
append-flags -fwrapv
fi
filter-flags -malign-double
[[ "${ARCH}" == "alpha" ]] && append-flags -fPIC
# https://bugs.gentoo.org/show_bug.cgi?id=50309
if is-flagq -O3; then
is-flagq -fstack-protector-all && replace-flags -O3 -O2
use hardened && replace-flags -O3 -O2
fi
if tc-is-cross-compiler; then
OPT="-O1" CFLAGS="" LDFLAGS="" CC="" \
./configure --{build,host}=${CBUILD} || die "cross-configure failed"
emake python Parser/pgen || die "cross-make failed"
mv python hostpython
mv Parser/pgen Parser/hostpgen
make distclean
sed -i \
-e "/^HOSTPYTHON/s:=.*:=./hostpython:" \
-e "/^HOSTPGEN/s:=.*:=./Parser/hostpgen:" \
Makefile.pre.in || die "sed failed"
fi
# Export CXX so it ends up in /usr/lib/python2.X/config/Makefile.
tc-export CXX
# Set LDFLAGS so we link modules with -lpython2.7 correctly.
# Needed on FreeBSD unless Python 2.7 is already installed.
# Please query BSD team before removing this!
append-ldflags "-L."
local dbmliborder
if use gdbm; then
dbmliborder+="${dbmliborder:+:}gdbm"
fi
if use berkdb; then
dbmliborder+="${dbmliborder:+:}bdb"
fi
OPT="" econf \
--with-fpectl \
--enable-shared \
$(use_enable ipv6) \
$(use_with threads) \
$(use wide-unicode && echo "--enable-unicode=ucs4" || echo "--enable-unicode=ucs2") \
--infodir='${prefix}/share/info' \
--mandir='${prefix}/share/man' \
--with-dbmliborder="${dbmliborder}" \
--with-libc="" \
--enable-loadable-sqlite-extensions \
--with-system-expat \
--with-system-ffi
}
src_compile() {
emake EPYTHON="python${PV%%.*}" || die "emake failed"
}
src_test() {
# Tests will not work when cross compiling.
if tc-is-cross-compiler; then
elog "Disabling tests due to crosscompiling."
return
fi
# Byte compiling should be enabled here.
# Otherwise test_import fails.
python_enable_pyc
# Skip failing tests.
local skipped_tests="distutils gdb"
for test in ${skipped_tests}; do
mv "${S}/Lib/test/test_${test}.py" "${T}"
done
# Rerun failed tests in verbose mode (regrtest -w).
emake test EXTRATESTOPTS="-w" < /dev/tty
local result="$?"
for test in ${skipped_tests}; do
mv "${T}/test_${test}.py" "${S}/Lib/test/test_${test}.py"
done
elog "The following tests have been skipped:"
for test in ${skipped_tests}; do
elog "test_${test}.py"
done
elog "If you would like to run them, you may:"
elog "cd '${EPREFIX}$(python_get_libdir)/test'"
elog "and run the tests separately."
python_disable_pyc
if [[ "${result}" -ne 0 ]]; then
die "emake test failed"
fi
}
src_install() {
[[ -z "${ED}" ]] && ED="${D%/}${EPREFIX}/"
emake DESTDIR="${D}" altinstall maninstall || die "emake altinstall maninstall failed"
python_clean_installation_image -q
sed -e "s/\(LDFLAGS=\).*/\1/" -i "${ED}$(python_get_libdir)/config/Makefile" || die "sed failed"
mv "${ED}usr/bin/python${SLOT}-config" "${ED}usr/bin/python-config-${SLOT}"
# Fix collisions between different slots of Python.
mv "${ED}usr/bin/2to3" "${ED}usr/bin/2to3-${SLOT}"
mv "${ED}usr/bin/pydoc" "${ED}usr/bin/pydoc${SLOT}"
mv "${ED}usr/bin/idle" "${ED}usr/bin/idle${SLOT}"
rm -f "${ED}usr/bin/smtpd.py"
if use build; then
rm -fr "${ED}usr/bin/idle${SLOT}" "${ED}$(python_get_libdir)/"{bsddb,dbhash.py,idlelib,lib-tk,sqlite3,test}
else
use elibc_uclibc && rm -fr "${ED}$(python_get_libdir)/"{bsddb/test,test}
use berkdb || rm -fr "${ED}$(python_get_libdir)/"{bsddb,dbhash.py,test/test_bsddb*}
use sqlite || rm -fr "${ED}$(python_get_libdir)/"{sqlite3,test/test_sqlite*}
use tk || rm -fr "${ED}usr/bin/idle${SLOT}" "${ED}$(python_get_libdir)/"{idlelib,lib-tk}
fi
use threads || rm -fr "${ED}$(python_get_libdir)/multiprocessing"
use wininst || rm -f "${ED}$(python_get_libdir)/distutils/command/"wininst-*.exe
dodoc Misc/{ACKS,HISTORY,NEWS} || die "dodoc failed"
if use examples; then
insinto /usr/share/doc/${PF}/examples
doins -r "${S}/Tools" || die "doins failed"
fi
newconfd "${FILESDIR}/pydoc.conf" pydoc-${SLOT} || die "newconfd failed"
newinitd "${FILESDIR}/pydoc.init" pydoc-${SLOT} || die "newinitd failed"
if use kernel_linux; then
if [ -d "${ED}$(python_get_libdir)/plat-linux2" ];then
cp -r "${ED}$(python_get_libdir)/plat-linux2" \
"${ED}$(python_get_libdir)/plat-linux3" || die "copy plat-linux failed"
else
cp -r "${ED}$(python_get_libdir)/plat-linux3" \
"${ED}$(python_get_libdir)/plat-linux2" || die "copy plat-linux failed"
fi
fi
sed \
-e "s:@PYDOC_PORT_VARIABLE@:PYDOC${SLOT/./_}_PORT:" \
-e "s:@PYDOC@:pydoc${SLOT}:" \
-i "${ED}etc/conf.d/pydoc-${SLOT}" "${ED}etc/init.d/pydoc-${SLOT}" || die "sed failed"
}
pkg_preinst() {
if has_version "<${CATEGORY}/${PN}-${SLOT}" && ! has_version "${CATEGORY}/${PN}:2.7"; then
python_updater_warning="1"
fi
}
eselect_python_update() {
[[ -z "${EROOT}" || (! -d "${EROOT}" && -d "${ROOT}") ]] && EROOT="${ROOT%/}${EPREFIX}/"
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
python_mod_optimize -f -x "/(site-packages|test|tests)/" $(python_get_libdir)
if [[ "${python_updater_warning}" == "1" ]]; then
ewarn
ewarn "\e[1;31m************************************************************************\e[0m"
ewarn
ewarn "You have just upgraded from an older version of Python."
ewarn "You should switch active version of Python ${PV%%.*} and run"
ewarn "'python-updater \${options}' to rebuild Python modules."
ewarn
ewarn "\e[1;31m************************************************************************\e[0m"
ewarn
local n
for ((n = 0; n < 12; n++)); do
echo -ne "\a"
sleep 1
done
fi
}
pkg_postrm() {
eselect_python_update
python_mod_cleanup $(python_get_libdir)
}