Gentoo Archives: gentoo-commits

From: Fabian Groffen <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/proj/prefix:master commit in: dev-lang/python/files/, dev-lang/python/
Date: Mon, 14 Dec 2015 20:36:44
Message-Id: 1450125387.5b7d44080e28464013050e51457ab77b1665acc6.grobian@gentoo
1 commit: 5b7d44080e28464013050e51457ab77b1665acc6
2 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
3 AuthorDate: Mon Dec 14 20:36:27 2015 +0000
4 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
5 CommitDate: Mon Dec 14 20:36:27 2015 +0000
6 URL: https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=5b7d4408
7
8 dev-lang/python: add python-3.5.1, fixes bug #563834
9
10 Package-Manager: portage-2.2.20-prefix
11
12 dev-lang/python/Manifest | 3 +
13 dev-lang/python/files/3.5-secondary-targets.patch | 19 +
14 dev-lang/python/python-3.5.1.ebuild | 412 ++++++++++++++++++++++
15 3 files changed, 434 insertions(+)
16
17 diff --git a/dev-lang/python/Manifest b/dev-lang/python/Manifest
18 index 2c0f64a..89f33a1 100644
19 --- a/dev-lang/python/Manifest
20 +++ b/dev-lang/python/Manifest
21 @@ -4,15 +4,18 @@ DIST Python-2.7.8.tar.xz 10525244 SHA256 edde10a0cb7d14e2735e682882d5b287028d148
22 DIST Python-3.2.5.tar.xz 9221624 SHA256 8ccb9645b9779fc4550055b2ebb21a724ab7a63dee45643286eb4f79b2f84116 SHA512 6e71d01695c7b1e74d9781e4ac40a8d1560cae659d5351d392fc685b84316568d93740a99d2ed878dd87d4ce1708d0474cb01c6bad7b3dab610c639f3255b09d WHIRLPOOL d5e5fae5e1d4110861e1e1dac00c9812abbbc37205e8ce3cd268535ab9f66e24038ab4778af8bb834fd472eaa0281730f1f2fabdf6dffc4f6b54ef32c1d75953
23 DIST Python-3.3.3.tar.xz 12057744 SHA256 339275b30a1a3fef1589016bf6302c14e870f7a6fd2522bf87a6c2c6d383c685 SHA512 6acd905d2ae70a259de1d502c90ce9cc831b03cd32930d55bdce1f6dd4b2657c4bb8698e46f6558253338046c43ee842befa2d62e35eeb82b82659acbe6ea0aa WHIRLPOOL 680a88bc7ca312a71237350c06573d5ed6138d826613a6a8ad9e953181561966c9a9f64b176226a627175b8bb5d13755bb7cabe20ee9510ced5da14185e092a4
24 DIST Python-3.4.3.tar.xz 14421964 SHA256 b5b3963533768d5fc325a4d7a6bd6f666726002d696f1d399ec06b043ea996b8 SHA512 55b2d7c07da8ad3a3971b4687da2e45809c6f1474732e93b0432f121f287d0b63ad8a9bf381987ea70f47a03d9474c3e55b7d86d14800bf7ef29b3324d8d35b9 WHIRLPOOL f851dedc6a1ea35adec83d60784a5fbcd9dfcf6aa8858bb5ada114fa2ff55add1fbf323ab94ec039ecdedb26d59e8f2e6e171cd9fc1ed41ad9cfa434a555cff3
25 +DIST Python-3.5.1.tar.xz 14830408 SHA256 c6d57c0c366d9060ab6c0cdf889ebf3d92711d466cc0119c441dbf2746f725c9 SHA512 261c9e42ae351853c718707a8887817e308b3ba7a37e9463a0bc8f50ee9be9ac1a011b2891f8877ecdb40beab99279bcfa8e04f813b8998fcf6cefb7fd52d850 WHIRLPOOL 7ff4ddb852c74f75d1f327e418f5af09ae66403cc3fb2431ab31786c046cec2d761ee57e8c6674a92bb08f95cfff7c7c7d5ddd965994096a0380fbd6b55fcc8f
26 DIST python-gentoo-patches-2.7.10-0.tar.xz 12892 SHA256 c9a838bd62ae50cc385da23a837acfd05f2b74e4f086c9c76eb4d3aa5366ef6d SHA512 5f100944635e360691dc0a2b340a906646c4ae9ee558246ddffc56e8b15d389f25f1fbdc1db4cc08e7d29560d04d66b058b3904902899d58ecae8c408ebdf056 WHIRLPOOL f69e9a518bb7ee50c1b262a21e70e1e2443f859ee6d2f4fa84421120dbd054a06ce8dd6cfea8512cbc64bce806322b879c25c561d5eb05e1ba6cc15035b373a9
27 DIST python-gentoo-patches-2.7.11-0.tar.xz 12916 SHA256 e14b47bb1fd64d366d7dfb8339cc2cbf4a53fc288b11dd83f575eb36a8a6408d SHA512 f0447bb699a163afc08df39b111394377539935546ae23732d7239e78d2bff0c04bc94949f86aef0c1be83736127dbd25c2c531e49befed2d638c3cd4940ac52 WHIRLPOOL 305992849d9d244da1e308e739c9bf62a3ef5c74eb65c765bdc666fb5767eb16c7a609f7c442c17da17f76c3ab81e4b09fa8c21e43f89366539a6a9d656bea77
28 DIST python-gentoo-patches-2.7.8-0.tar.xz 14016 SHA256 22ca5eab8e1702f220c272c57359f547b753b88d59b53ab95c7985c17f4f90ec SHA512 17020c8a2039cc073c973e213e77dc67ad9ed4ae7f5fafb931933943aa745733309c46e3972bfde85d112cdef6d47aa91868a614db08bb135c29051999c3df4e WHIRLPOOL 96f0e5c7329cc886d979ec782ffd3c63461f49ba112f0d95e5528d7f15048170cd4e52b78cb4100839d509ef28b927bf7a0f1a610fcf4ec562730a284f8c9fc3
29 DIST python-gentoo-patches-3.2.5-1.tar.xz 14628 SHA256 0acc5531421781ab7f30e6fc8a502f202b79aa285b4f411eb16ea0a9e6d958c1 SHA512 1abbd53e92466d258802717309e1839ae931b8a4b0a5a27d4d0da748e71cf96ac47c6837bdbae5dd6921a46cee339c178f86ff3108afe95e6a0a42c4f4300791 WHIRLPOOL de003cccb8b311413889713d66b7987f28a1f906cc9642621d1fd2a379ceae4f0f901c137503d808dc3da7295ac611de09781bf8661cdbcd14c1d7c94ba489c2
30 DIST python-gentoo-patches-3.3.3-0.tar.xz 12992 SHA256 38b5c604416947fdd7d87ada2ccd3febf7407f00c1e67e6a99be8765f1b25c49 SHA512 d803b287c0f407c68dd766974296239419fb35441f1796081681f28d17b1f6c7e50e0aae807ad147469eb586db8fe486a013a166cb76e08f2b7a9ba39acb1760 WHIRLPOOL 09a9dbd1831c2e7022f4df27b57435dd1df7eace294e8fa069ce5fa5c1719f64ba9bcd8f27d614a8c13ee8605db37c7e75c13fa14885b76ce289667bf2871aaf
31 DIST python-gentoo-patches-3.4.3-0.tar.xz 11736 SHA256 917a9d98d40a91379c81ea57922a8632ba3c6f6db6f304ed6262bc88c5044946 SHA512 7ad1b30cf8bb7900fe518ed71e4ee55dd92ce7e23ae583a1f2f851b26cfa8c4f4271d28f418e780f3725a48d4ca8eeb8fd083f850810c66c29fb08c430828d72 WHIRLPOOL 074e8c0055b49a028eebda21d1acfb8a25ec968eb8b350c2bed37e042f9f354871e413db13e0ef2fe41d7e56d647178a7b3622019f36c4819c2c68f088366eb1
32 +DIST python-gentoo-patches-3.5.1-0.tar.xz 11788 SHA256 668fabdb9326ba3df81dd299619d5245b7806934e9341ef89a06f90c9a98018b SHA512 3948af801e3e70b55b15165d6cc56fb33cdb9fcc9d80b913550c8609273bad28db0c10ec64cb14d010b80020716a1e45d720e08864f6ac850291cb1713800a1a WHIRLPOOL 2fd3b25186c26412dc642f76228d8e75f24cdc7452407dd105f027be5841b1b865f6b5b74a0072a0299153e5d5af699542253b366e4eb78dfbf114ad02b14bcc
33 DIST python-prefix-2.7.10-gentoo-patches.tar.bz2 16922 SHA256 9fe4df587363c439f1f29885b4b2a1238d16861667966b279dc1019cb904efa4 SHA512 a016e1572276dbbe0fc045d723b592b31573f99b60370f0c1506f10fd9a632cc879bdc4a2060c6a5ff411f26179189517ff4c4beb6979a5727e0dc17de935fe2 WHIRLPOOL 73542d16f9f64acb2cb941ce659d981d6d8b8a8cba9ef4f41c4b987665beedb125a6ad4a7badb5eb12092d916e1ab807330a2fcefc7914ae9708569d54faa7b6
34 DIST python-prefix-2.7.11-gentoo-patches-r0.tar.xz 17348 SHA256 c02e37fc75fa280cfed86d20df3dc4c8a7ff46f18eb67b268d75209f0c1a2fc6 SHA512 c181953cc30c94935a06f7511b5d641a1b45127a69ccf9e8e22cb31c0da6e54e7e4ccc5c5f4a15889c079d5b1d3c74b94e8da49dc018c807b6b8b0376cb70e76 WHIRLPOOL a8dcda32eadb3c3e1908f5a493b06046190d2f53347edfe3ef859926fe2e741535c9a9ad0ebbe1b0ea011b858f6ee21c04f806469b7249d453e6ae4b7a6cd2b2
35 DIST python-prefix-2.7.8-gentoo-patches.tar.bz2 17154 SHA256 6c5f171f15f662c2b88258ebff152224a7003c43e025be860baf99913d00a8b1 SHA512 fe53cf969e70744ed6c66757e507f55eea031fa98e08f1846e3c51b968eb8d91a377c9c47cbc5cd469715c37d71b70dd1dc46fdbb52cab372179acb497a81643 WHIRLPOOL f966f3dc68f7cf171aeef0226a72616d42f13e9b085a772aa7221b1898a74e0b31c74350c7114fc6a39ab739877d5e12be1755357e2821f8b026af61fa99b4b3
36 DIST python-prefix-3.2.5-gentoo-patches-r0.tar.bz2 9594 SHA256 350924a35c352915d619aea9077ef26707b2621683cca926de5cb55b5dc429fa SHA512 63eb12cea50a9d3a557071f47f4d8200153c495f7e8f9853508194b56b8e16da956fe0e6b790085f4ecdcc8d5c29a0c50664fee1bd522d52d98a43c2bceb28ea WHIRLPOOL e5335f7df1bf21f5303e90048c15d5cf0d539b269a428a417e8678c74f8ab630691456c6e02476bf223531d12e44f7cfb71f6b631f371c8a0dc454e4e5d3607a
37 DIST python-prefix-3.3.3-gentoo-patches-r2.tar.bz2 13776 SHA256 7e90671d26b60b874748efc95171f7bed149637b1d4aa34752d12fdac06d2d85 SHA512 9859d5367ae1d655572236ffdeb49ac58ae4cf48a556428a9cfb80ac21552d0d8b1c89461f31e6a8dbfdfbc9ced01f510400963571d810e79156f2a3f753fffd WHIRLPOOL b5d45333fea0610e0efba2f0d113337d9004459ec733691406518709ff4c191060d868ead7a0db0e65f89e953d03fb164c5cd1dcc128a5c0e5af93fa7fc0ffd4
38 DIST python-prefix-3.4.3-gentoo-patches-r0.tar.xz 12808 SHA256 bb51649f6a586640463dd742170ff2fdb8c906128a97b1c0bb2b9cad0fe82d56 SHA512 714e5cfa03cfd290a821dea641b91c4358a25bb1bcb47050b1cf321f0defa7e060a4cdd967bc356701642230b51f3c74476af96ff58a6f933301171e12ccfac8 WHIRLPOOL f7ff0e0bebbeee221a18d5078f12c77922c7621e00f19254e72f68767647a7d2ff9312366b62023a7d4283def2d7f509572ad657bbb2c132355ee637c5697b0c
39 +DIST python-prefix-3.5.1-gentoo-patches-r0.tar.xz 12724 SHA256 e03203bc1e83ebc112adbcc8d475628caea94099dc2f5f18714e5a6d2a8aa3d9 SHA512 26ab0126188663d8f31355e76ccc7eac933b0a5f59b1d3977985492eec699ea845fffdadce20828ecb5a4a8c48c95bf265c57456bafdea167a4e5881b0f6bbe2 WHIRLPOOL 58a29b1075659c57d6709ca055721810570f91d873138da9cbfaa0fd14a90e04164cf59e9ca1182bbb714b9fe937c81c2856d4b880dbdcf6f599c1d096d3c4d9
40
41 diff --git a/dev-lang/python/files/3.5-secondary-targets.patch b/dev-lang/python/files/3.5-secondary-targets.patch
42 new file mode 100644
43 index 0000000..eb3b0c7
44 --- /dev/null
45 +++ b/dev-lang/python/files/3.5-secondary-targets.patch
46 @@ -0,0 +1,19 @@
47 +Mark all targets as "secondary"
48 +
49 +This allows make to avoid rebuilding unnecessary intermediate files, which
50 +is useful when cross-compiling.
51 +
52 +See Parser/pgen and Programs/_freeze_importlib in Makefile.pre.in.
53 +
54 +diff --git a/Makefile.pre.in b/Makefile.pre.in
55 +--- a/Makefile.pre.in
56 ++++ b/Makefile.pre.in
57 +@@ -1672,6 +1672,8 @@
58 + .PHONY: smelly funny patchcheck touch altmaninstall commoninstall
59 + .PHONY: gdbhooks
60 +
61 ++.SECONDARY:
62 ++
63 + # IF YOU PUT ANYTHING HERE IT WILL GO AWAY
64 + # Local Variables:
65 + # mode: makefile
66
67 diff --git a/dev-lang/python/python-3.5.1.ebuild b/dev-lang/python/python-3.5.1.ebuild
68 new file mode 100644
69 index 0000000..471af4c
70 --- /dev/null
71 +++ b/dev-lang/python/python-3.5.1.ebuild
72 @@ -0,0 +1,412 @@
73 +# Copyright 1999-2015 Gentoo Foundation
74 +# Distributed under the terms of the GNU General Public License v2
75 +# $Id$
76 +
77 +EAPI="5"
78 +WANT_LIBTOOL="none"
79 +
80 +inherit autotools eutils flag-o-matic multilib pax-utils python-utils-r1 toolchain-funcs
81 +
82 +MY_P="Python-${PV/_/}"
83 +PATCHSET_VERSION="3.5.1-0"
84 +PREFIX_PATCHREV="r0"
85 +
86 +DESCRIPTION="An interpreted, interactive, object-oriented programming language"
87 +HOMEPAGE="http://www.python.org/"
88 +SRC_URI="http://www.python.org/ftp/python/${PV%_rc*}/${MY_P}.tar.xz
89 + https://dev.gentoo.org/~floppym/python/python-gentoo-patches-${PATCHSET_VERSION}.tar.xz
90 + https://dev.gentoo.org/~grobian/distfiles/python-prefix-${PV}-gentoo-patches-${PREFIX_PATCHREV}.tar.xz"
91 +
92 +LICENSE="PSF-2"
93 +SLOT="3.5/3.5m"
94 +KEYWORDS="~ppc-aix ~x64-freebsd ~x86-freebsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
95 +IUSE="aqua build elibc_uclibc examples gdbm hardened ipv6 libressl +ncurses +readline sqlite +ssl +threads tk wininst +xml"
96 +
97 +# Do not add a dependency on dev-lang/python to this ebuild.
98 +# If you need to apply a patch which requires python for bootstrapping, please
99 +# run the bootstrap code on your dev box and include the results in the
100 +# patchset. See bug 447752.
101 +
102 +RDEPEND="app-arch/bzip2:0=
103 + app-arch/xz-utils:0=
104 + >=sys-libs/zlib-1.1.3:0=
105 + virtual/libffi
106 + virtual/libintl
107 + gdbm? ( sys-libs/gdbm:0=[berkdb] )
108 + ncurses? (
109 + >=sys-libs/ncurses-5.2:0=
110 + readline? ( >=sys-libs/readline-4.1:0= )
111 + )
112 + sqlite? ( >=dev-db/sqlite-3.3.8:3= )
113 + ssl? (
114 + !libressl? ( dev-libs/openssl:0= )
115 + libressl? ( dev-libs/libressl:= )
116 + )
117 + tk? (
118 + >=dev-lang/tcl-8.0:0=
119 + >=dev-lang/tk-8.0:0=[-aqua]
120 + dev-tcltk/blt:0=
121 + dev-tcltk/tix
122 + )
123 + xml? ( >=dev-libs/expat-2.1:0= )
124 + !!<sys-apps/sandbox-2.6-r1"
125 +DEPEND="${RDEPEND}
126 + virtual/pkgconfig
127 + !sys-devel/gcc[libffi(-)]"
128 +RDEPEND+=" !build? ( app-misc/mime-types )"
129 +PDEPEND=">=app-eselect/eselect-python-20151117-r1"
130 +
131 +S="${WORKDIR}/${MY_P}"
132 +
133 +PYVER=${SLOT%/*}
134 +
135 +src_prepare() {
136 + # Ensure that internal copies of expat, libffi and zlib are not used.
137 + rm -fr Modules/expat
138 + rm -fr Modules/_ctypes/libffi*
139 + rm -fr Modules/zlib
140 +
141 + if tc-is-cross-compiler; then
142 + # Invokes BUILDPYTHON, which is built for the host arch
143 + local EPATCH_EXCLUDE="*_regenerate_platform-specific_modules.patch"
144 + fi
145 +
146 + EPATCH_SUFFIX="patch" epatch "${WORKDIR}/patches"
147 + epatch "${FILESDIR}/${PN}-3.4.3-ncurses-pkg-config.patch"
148 + epatch "${FILESDIR}/3.5-secondary-targets.patch"
149 +
150 + # Prefix' round of patches
151 + # http://prefix.gentooexperimental.org:8000/python-patches-3_3
152 + EPATCH_EXCLUDE="${excluded_patches}" EPATCH_SUFFIX="patch" \
153 + epatch "${WORKDIR}"/python-prefix-${PV}-gentoo-patches-${PREFIX_PATCHREV}
154 +
155 + # we provide a fully working readline also on Darwin, so don't force
156 + # usage of less functional libedit
157 + sed -i -e 's/__APPLE__/__NO_MUCKING_AROUND__/g' Modules/readline.c || die
158 +
159 + # We may have wrapped /usr/ccs/bin/nm on AIX for long TMPDIR.
160 + sed -i -e "/^NM=.*nm$/s,^.*$,NM=$(tc-getNM)," Modules/makexp_aix || die
161 +
162 + # Make sure python doesn't use the host libffi.
163 + use prefix && epatch "${FILESDIR}/python-3.2-libffi-pkgconfig.patch"
164 +
165 + sed -i -e "s:@@GENTOO_LIBDIR@@:$(get_libdir):g" \
166 + configure.ac \
167 + Lib/distutils/command/install.py \
168 + Lib/distutils/sysconfig.py \
169 + Lib/site.py \
170 + Lib/sysconfig.py \
171 + Lib/test/test_site.py \
172 + Makefile.pre.in \
173 + Modules/getpath.c \
174 + Modules/Setup.dist \
175 + setup.py || die "sed failed to replace @@GENTOO_LIBDIR@@"
176 +
177 + #sed -i -e 's/\$(GRAMMAR_H): \$(GRAMMAR_INPUT) \$(PGEN)/$(GRAMMAR_H): \$(GRAMMAR_INPUT)/' Makefile.pre.in || die
178 +
179 + # workaround a development build env problem and muck around
180 + # framework install to get the best of both worlds (non-standard)
181 + sed -i \
182 + -e "s:FRAMEWORKINSTALLAPPSPREFIX=\":FRAMEWORKINSTALLAPPSPREFIX=\"${EPREFIX}:" \
183 + -e '/RUNSHARED=DYLD_FRAMEWORK_PATH/s/FRAMEWORK/LIBRARY/g' \
184 + configure.ac configure || die
185 + sed -i -e '/find/s/$/ || true/' Mac/PythonLauncher/Makefile.in || die
186 +
187 + # Disable ABI flags.
188 + sed -e "s/ABIFLAGS=\"\${ABIFLAGS}.*\"/:/" -i configure.ac || die "sed failed"
189 +
190 + epatch_user
191 +
192 + eautoreconf
193 +}
194 +
195 +src_configure() {
196 + local disable
197 + use gdbm || disable+=" gdbm"
198 + use ncurses || disable+=" _curses _curses_panel"
199 + use readline || disable+=" readline"
200 + use sqlite || disable+=" _sqlite3"
201 + use ssl || export PYTHON_DISABLE_SSL="1"
202 + use tk || disable+=" _tkinter"
203 + use xml || disable+=" _elementtree pyexpat" # _elementtree uses pyexpat.
204 + export PYTHON_DISABLE_MODULES="${disable}"
205 +
206 + if ! use xml; then
207 + ewarn "You have configured Python without XML support."
208 + ewarn "This is NOT a recommended configuration as you"
209 + ewarn "may face problems parsing any XML documents."
210 + fi
211 +
212 + if [[ -n "${PYTHON_DISABLE_MODULES}" ]]; then
213 + einfo "Disabled modules: ${PYTHON_DISABLE_MODULES}"
214 + fi
215 +
216 + if [[ "$(gcc-major-version)" -ge 4 ]]; then
217 + append-flags -fwrapv
218 + fi
219 +
220 + filter-flags -malign-double
221 +
222 + [[ "${ARCH}" == "alpha" ]] && append-flags -fPIC
223 +
224 + # https://bugs.gentoo.org/show_bug.cgi?id=50309
225 + if is-flagq -O3; then
226 + is-flagq -fstack-protector-all && replace-flags -O3 -O2
227 + use hardened && replace-flags -O3 -O2
228 + fi
229 +
230 + # Export CC so even AIX will use gcc instead of xlc_r.
231 + # Export CXX so it ends up in /usr/lib/python3.X/config/Makefile.
232 + tc-export CC CXX
233 +
234 + # The configure script fails to use pkg-config correctly.
235 + # http://bugs.python.org/issue15506
236 + export ac_cv_path_PKG_CONFIG=$(tc-getPKG_CONFIG)
237 +
238 + # Set LDFLAGS so we link modules with -lpython3.2 correctly.
239 + # Needed on FreeBSD unless Python 3.2 is already installed.
240 + # Please query BSD team before removing this!
241 + append-ldflags "-L."
242 +
243 + # make sure setup.py considers Prefix' paths before system ones
244 + use prefix && append-cppflags -I"${EPREFIX}"/usr/include
245 + use prefix && append-ldflags -L"${EPREFIX}"/lib -L"${EPREFIX}"/usr/lib
246 +
247 + local dbmliborder
248 + if use gdbm; then
249 + dbmliborder+="${dbmliborder:+:}gdbm"
250 + fi
251 +
252 + BUILD_DIR="${WORKDIR}/${CHOST}"
253 + mkdir -p "${BUILD_DIR}" || die
254 + cd "${BUILD_DIR}" || die
255 +
256 + if use aqua ; then
257 + ECONF_SOURCE="${S}" OPT="" \
258 + econf \
259 + --enable-framework="${EPREFIX}"/usr/lib \
260 + --config-cache
261 + fi
262 +
263 + # pymalloc #452720
264 + local myeconfargs=(
265 + $(use aqua && echo --config-cache) \
266 + --with-fpectl
267 + --enable-shared
268 + $(use_enable ipv6)
269 + $(use_with threads)
270 + --infodir='${prefix}/share/info'
271 + --mandir='${prefix}/share/man'
272 + --with-computed-gotos
273 + --with-dbmliborder="${dbmliborder}"
274 + --with-libc=
275 + --enable-loadable-sqlite-extensions
276 + --without-ensurepip
277 + --with-system-expat
278 + --with-system-ffi
279 + --without-pymalloc
280 + )
281 +
282 + ECONF_SOURCE="${S}" OPT="" econf "${myeconfargs[@]}"
283 +
284 + if use threads && grep -q "#define POSIX_SEMAPHORES_NOT_ENABLED 1" pyconfig.h; then
285 + eerror "configure has detected that the sem_open function is broken."
286 + eerror "Please ensure that /dev/shm is mounted as a tmpfs with mode 1777."
287 + die "Broken sem_open function (bug 496328)"
288 + fi
289 +}
290 +
291 +src_compile() {
292 + # Avoid regenerating these for cross-compiles
293 + touch Include/graminit.h Python/graminit.c Python/importlib.h Python/importlib_external.h || die
294 +
295 + cd "${BUILD_DIR}" || die
296 +
297 + emake CPPFLAGS= CFLAGS= LDFLAGS=
298 +
299 + # Work around bug 329499. See also bug 413751 and 457194.
300 + if has_version dev-libs/libffi[pax_kernel]; then
301 + pax-mark E python
302 + else
303 + pax-mark m python
304 + fi
305 +}
306 +
307 +src_test() {
308 + # Tests will not work when cross compiling.
309 + if tc-is-cross-compiler; then
310 + elog "Disabling tests due to crosscompiling."
311 + return
312 + fi
313 +
314 + cd "${BUILD_DIR}" || die
315 +
316 + # Skip failing tests.
317 + local skipped_tests="gdb"
318 +
319 + for test in ${skipped_tests}; do
320 + mv "${S}"/Lib/test/test_${test}.py "${T}"
321 + done
322 +
323 + local -x PYTHONDONTWRITEBYTECODE=
324 + emake test EXTRATESTOPTS="-u-network" CPPFLAGS= CFLAGS= LDFLAGS= < /dev/tty
325 + local result=$?
326 +
327 + for test in ${skipped_tests}; do
328 + mv "${T}/test_${test}.py" "${S}"/Lib/test
329 + done
330 +
331 + elog "The following tests have been skipped:"
332 + for test in ${skipped_tests}; do
333 + elog "test_${test}.py"
334 + done
335 +
336 + elog "If you would like to run them, you may:"
337 + elog "cd '${EPREFIX}/usr/$(get_libdir)/python${PYVER}/test'"
338 + elog "and run the tests separately."
339 +
340 + if [[ ${result} -ne 0 ]]; then
341 + die "emake test failed"
342 + fi
343 +}
344 +
345 +src_install() {
346 + local libdir=${ED}/usr/$(get_libdir)/python${PYVER}
347 +
348 + cd "${BUILD_DIR}" || die
349 +
350 + emake DESTDIR="${D}" altinstall
351 +
352 + if use aqua ; then
353 + # avoid config.status to be triggered
354 + find Mac -name "Makefile" -exec touch \{\} + || die
355 +
356 + emake DESTDIR="${D}" -C Mac \
357 + install_Python install_PythonLauncher install_IDLE \
358 + || die
359 +
360 + local fwdir=/usr/$(get_libdir)/Python.framework/Versions/${SLOT}
361 + ln -s "${EPREFIX}"/usr/include/python${SLOT} \
362 + "${ED}${fwdir}"/Headers || die
363 + ln -s "${EPREFIX}"/usr/lib/libpython${SLOT}.dylib \
364 + "${ED}${fwdir}"/Python || die
365 + fi
366 +
367 + sed \
368 + -e "s/\(CONFIGURE_LDFLAGS=\).*/\1/" \
369 + -e "s/\(PY_LDFLAGS=\).*/\1/" \
370 + -i "${libdir}/config-${PYVER}"*/Makefile || die "sed failed"
371 +
372 + # Fix collisions between different slots of Python.
373 + rm -f "${ED}usr/$(get_libdir)/libpython3.so"
374 +
375 + # Cheap hack to get version with ABIFLAGS
376 + local abiver=$(cd "${ED}usr/include"; echo python*)
377 + # Replace python3.X with a symlink if appropriate
378 + if [[ ${abiver} != python${PYVER} ]]; then
379 + rm "${ED}usr/bin/python${PYVER}" || die
380 + dosym "${abiver}" "/usr/bin/python${PYVER}"
381 + fi
382 +
383 + use elibc_uclibc && rm -fr "${libdir}/test"
384 + use sqlite || rm -fr "${libdir}/"{sqlite3,test/test_sqlite*}
385 + use tk || rm -fr "${ED}usr/bin/idle${PYVER}" "${libdir}/"{idlelib,tkinter,test/test_tk*}
386 +
387 + use threads || rm -fr "${libdir}/multiprocessing"
388 + use wininst || rm -f "${libdir}/distutils/command/"wininst-*.exe
389 +
390 + dodoc "${S}"/Misc/{ACKS,HISTORY,NEWS}
391 +
392 + if use examples; then
393 + insinto /usr/share/doc/${PF}/examples
394 + find "${S}"/Tools -name __pycache__ -print0 | xargs -0 rm -fr
395 + doins -r "${S}"/Tools
396 + fi
397 + insinto /usr/share/gdb/auto-load/usr/$(get_libdir) #443510
398 + if use aqua ; then
399 + # we do framework, so the emake trick below returns a pathname
400 + # since that won't work here, use a (cheap) trick instead
401 + local libname=libpython${SLOT}
402 + else
403 + local libname=$(printf 'e:\n\t@echo $(INSTSONAME)\ninclude Makefile\n' | \
404 + emake --no-print-directory -s -f - 2>/dev/null)
405 + fi
406 + newins "${S}"/Tools/gdb/libpython.py "${libname}"-gdb.py
407 +
408 + newconfd "${FILESDIR}/pydoc.conf" pydoc-${PYVER}
409 + newinitd "${FILESDIR}/pydoc.init" pydoc-${PYVER}
410 + sed \
411 + -e "s:@PYDOC_PORT_VARIABLE@:PYDOC${PYVER/./_}_PORT:" \
412 + -e "s:@PYDOC@:pydoc${PYVER}:" \
413 + -i "${ED}etc/conf.d/pydoc-${PYVER}" "${ED}etc/init.d/pydoc-${PYVER}" || die "sed failed"
414 +
415 + # for python-exec
416 + local vars=( EPYTHON PYTHON_SITEDIR PYTHON_SCRIPTDIR )
417 +
418 + # if not using a cross-compiler, use the fresh binary
419 + if ! tc-is-cross-compiler; then
420 + local -x PYTHON=./python
421 + local -x LD_LIBRARY_PATH=${LD_LIBRARY_PATH+${LD_LIBRARY_PATH}:}.
422 + else
423 + vars=( PYTHON "${vars[@]}" )
424 + fi
425 +
426 + python_export "python${PYVER}" "${vars[@]}"
427 + echo "EPYTHON='${EPYTHON}'" > epython.py || die
428 + python_domodule epython.py
429 +
430 + # python-exec wrapping support
431 + local pymajor=${PYVER%.*}
432 + mkdir -p "${D}${PYTHON_SCRIPTDIR}" || die
433 + # python and pythonX
434 + ln -s "../../../bin/${abiver}" \
435 + "${D}${PYTHON_SCRIPTDIR}/python${pymajor}" || die
436 + ln -s "python${pymajor}" \
437 + "${D}${PYTHON_SCRIPTDIR}/python" || die
438 + # python-config and pythonX-config
439 + ln -s "../../../bin/${abiver}-config" \
440 + "${D}${PYTHON_SCRIPTDIR}/python${pymajor}-config" || die
441 + ln -s "python${pymajor}-config" \
442 + "${D}${PYTHON_SCRIPTDIR}/python-config" || die
443 + # 2to3, pydoc, pyvenv
444 + ln -s "../../../bin/2to3-${PYVER}" \
445 + "${D}${PYTHON_SCRIPTDIR}/2to3" || die
446 + ln -s "../../../bin/pydoc${PYVER}" \
447 + "${D}${PYTHON_SCRIPTDIR}/pydoc" || die
448 + ln -s "../../../bin/pyvenv-${PYVER}" \
449 + "${D}${PYTHON_SCRIPTDIR}/pyvenv" || die
450 +
451 + # Compatibility link for stuff that calls ${PYTHON}-config
452 + # Remove this when all revdeps have been fixed to not do that.
453 + dosym "${abiver}-config" "/usr/bin/python${PYVER}-config"
454 +}
455 +
456 +pkg_preinst() {
457 + if has_version "<${CATEGORY}/${PN}-${PYVER}" && ! has_version ">=${CATEGORY}/${PN}-${PYVER}_alpha"; then
458 + python_updater_warning="1"
459 + fi
460 +}
461 +
462 +eselect_python_update() {
463 + if [[ -z "$(eselect python show)" || ! -f "${EROOT}usr/bin/$(eselect python show)" ]]; then
464 + eselect python update
465 + fi
466 +
467 + if [[ -z "$(eselect python show --python${PV%%.*})" || ! -f "${EROOT}usr/bin/$(eselect python show --python${PV%%.*})" ]]; then
468 + eselect python update --python${PV%%.*}
469 + fi
470 +}
471 +
472 +pkg_postinst() {
473 + eselect_python_update
474 +
475 + if [[ "${python_updater_warning}" == "1" ]]; then
476 + ewarn "You have just upgraded from an older version of Python."
477 + ewarn
478 + ewarn "Please adjust PYTHON_TARGETS (if so desired), and run emerge with the --newuse or --changed-use option to rebuild packages installing python modules."
479 + fi
480 +}
481 +
482 +pkg_postrm() {
483 + eselect_python_update
484 +}