Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] dev/mgorny:master commit in: dev-binpkg/pypy/
Date: Fri, 27 Nov 2015 16:48:07
Message-Id: 1448642866.e6c2c53790f5836491c1a88bbd6e52d1d507ca85.mgorny@gentoo
1 commit: e6c2c53790f5836491c1a88bbd6e52d1d507ca85
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Fri Nov 27 16:47:46 2015 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Fri Nov 27 16:47:46 2015 +0000
6 URL: https://gitweb.gentoo.org/dev/mgorny.git/commit/?id=e6c2c537
7
8 dev-binpkg/pypy: Bump to 4.0.1
9
10 dev-binpkg/pypy/pypy-4.0.1.ebuild | 193 ++++++++++++++++++++++++++++++++++++++
11 1 file changed, 193 insertions(+)
12
13 diff --git a/dev-binpkg/pypy/pypy-4.0.1.ebuild b/dev-binpkg/pypy/pypy-4.0.1.ebuild
14 new file mode 100644
15 index 0000000..0c8b627
16 --- /dev/null
17 +++ b/dev-binpkg/pypy/pypy-4.0.1.ebuild
18 @@ -0,0 +1,193 @@
19 +# Copyright 1999-2015 Gentoo Foundation
20 +# Distributed under the terms of the GNU General Public License v2
21 +# $Header: /var/cvsroot/gentoo-x86/dev-python/pypy/pypy-2.6.0.ebuild,v 1.1 2015/06/04 18:46:39 mgorny Exp $
22 +
23 +EAPI=5
24 +
25 +PYTHON_COMPAT=( python2_7 pypy )
26 +inherit check-reqs eutils multilib multiprocessing pax-utils python-any-r1 toolchain-funcs versionator
27 +
28 +CPY_PATCHSET_VERSION="2.7.10-0"
29 +
30 +DESCRIPTION="A fast, compliant alternative implementation of the Python language"
31 +HOMEPAGE="http://pypy.org/"
32 +SRC_URI="https://bitbucket.org/pypy/pypy/downloads/${P}-src.tar.bz2"
33 +
34 +LICENSE="MIT"
35 +SLOT="0/$(get_version_component_range 1-2 ${PV})"
36 +KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
37 +IUSE="bzip2 +jit low-memory ncurses sandbox shadowstack sqlite cpu_flags_x86_sse2"
38 +
39 +DEPEND=">=sys-libs/zlib-1.1.3:0=
40 + virtual/libffi:0=
41 + virtual/libintl:0=
42 + dev-libs/expat:0=
43 + dev-libs/openssl:0=[-bindist]
44 + bzip2? ( app-arch/bzip2:0= )
45 + ncurses? ( sys-libs/ncurses:0= )
46 + app-arch/xz-utils
47 + ${PYTHON_DEPS}"
48 +
49 +S="${WORKDIR}/${P}-src"
50 +
51 +pkg_pretend() {
52 + if use low-memory; then
53 + if ! python_is_installed pypy; then
54 + eerror "USE=low-memory requires a (possibly old) version of dev-python/pypy"
55 + eerror "or dev-python/pypy-bin being installed. Please install it using e.g.:"
56 + eerror
57 + eerror " $ emerge -1v dev-python/pypy-bin"
58 + eerror
59 + eerror "before attempting to build dev-python/pypy[low-memory]."
60 + die "dev-python/pypy-bin (or dev-python/pypy) needs to be installed for USE=low-memory"
61 + fi
62 +
63 + CHECKREQS_MEMORY="1750M"
64 + use amd64 && CHECKREQS_MEMORY="3500M"
65 + else
66 + CHECKREQS_MEMORY="3G"
67 + use amd64 && CHECKREQS_MEMORY="6G"
68 + fi
69 +
70 + check-reqs_pkg_pretend
71 +
72 + [[ ${PYPY_BINPKG_STORE} ]] || die 'PYPY_BINPKG_STORE unset, wtf?!'
73 +}
74 +
75 +pkg_setup() {
76 + pkg_pretend
77 +
78 + if python_is_installed pypy; then
79 + if [[ ! ${EPYTHON} || ${EPYTHON} == pypy ]] || use low-memory; then
80 + einfo "Using already-installed PyPy to perform the translation."
81 + local EPYTHON=pypy
82 + else
83 + einfo "Using ${EPYTHON} to perform the translation. Please note that upstream"
84 + einfo "recommends using PyPy for that. If you wish to do so, please unset"
85 + einfo "the EPYTHON variable."
86 + fi
87 + fi
88 +
89 + python-any-r1_pkg_setup
90 +
91 + local cpu
92 + if use amd64; then
93 + # common denominator between Intel & AMD
94 + cpu='x86-64'
95 + elif use x86; then
96 + if use cpu_flags_x86_sse2; then
97 + # lowest with SSE2
98 + cpu='pentium-m'
99 + else
100 + # lowest with SSE, compat. with athlon-xp
101 + # TODO: do we want to support something older?
102 + cpu='pentium3'
103 + fi
104 + else
105 + die "Unsupported arch ${ARCH}"
106 + fi
107 +
108 + export CFLAGS="-march=${cpu} -mtune=generic -O2 -pipe"
109 + export CXXFLAGS=${CFLAGS}
110 +
111 + elog "CFLAGS: ${CFLAGS}"
112 +}
113 +
114 +src_prepare() {
115 + epatch "${FILESDIR}"/2.5.0-shared-lib.patch # 517002
116 +
117 + epatch_user
118 +}
119 +
120 +src_compile() {
121 + tc-export CC
122 +
123 + local jit_backend
124 + if use jit; then
125 + jit_backend='--jit-backend='
126 +
127 + # We only need the explicit sse2 switch for x86.
128 + # On other arches we can rely on autodetection which uses
129 + # compiler macros. Plus, --jit-backend= doesn't accept all
130 + # the modern values...
131 +
132 + if use x86; then
133 + if use cpu_flags_x86_sse2; then
134 + jit_backend+=x86
135 + else
136 + jit_backend+=x86-without-sse2
137 + fi
138 + else
139 + jit_backend+=auto
140 + fi
141 + fi
142 +
143 + local args=(
144 + --shared
145 + $(usex jit -Ojit -O2)
146 + $(usex shadowstack --gcrootfinder=shadowstack '')
147 + $(usex sandbox --sandbox '')
148 +
149 + ${jit_backend}
150 + --make-jobs=$(makeopts_jobs)
151 +
152 + pypy/goal/targetpypystandalone
153 + )
154 +
155 + # Avoid linking against libraries disabled by use flags
156 + local opts=(
157 + bzip2:bz2
158 + ncurses:_minimal_curses
159 + )
160 +
161 + local opt
162 + for opt in "${opts[@]}"; do
163 + local flag=${opt%:*}
164 + local mod=${opt#*:}
165 +
166 + args+=(
167 + $(usex ${flag} --withmod --withoutmod)-${mod}
168 + )
169 + done
170 +
171 + local interp=( "${PYTHON}" )
172 + if use low-memory; then
173 + interp=( env PYPY_GC_MAX_DELTA=200MB
174 + "${PYTHON}" --jit loop_longevity=300 )
175 + fi
176 +
177 + set -- "${interp[@]}" rpython/bin/rpython --batch "${args[@]}"
178 + echo -e "\033[1m${@}\033[0m"
179 + "${@}" || die "compile error"
180 +
181 + pax-mark m "${ED%/}${INSDESTTREE}/pypy-c"
182 +}
183 +
184 +src_install() {
185 + local flags=( bzip2 jit ncurses sandbox shadowstack )
186 + use x86 && flags+=( cpu_flags_x86_sse2 )
187 + local f suffix="-${ARCH}"
188 +
189 + for f in ${flags[@]}; do
190 + use ${f} && suffix+="+${f#cpu_flags_x86_}"
191 + done
192 +
193 + local BIN_P=pypy-bin-${PV}
194 +
195 + einfo "Zipping PyPy ..."
196 + mkdir "${BIN_P}${suffix}"{,/include} || die
197 + mv pypy-c libpypy-c.so "${BIN_P}${suffix}"/ || die
198 + mv include/pypy_* "${BIN_P}${suffix}"/include/ || die
199 + chmod +x "${BIN_P}${suffix}"/pypy-c || die
200 +
201 + tar -cf "${BIN_P}${suffix}.tar" "${BIN_P}${suffix}" || die
202 + xz -vz9e "${BIN_P}${suffix}.tar" || die
203 +}
204 +
205 +# Yup, very hacky.
206 +pkg_preinst() {
207 + # integrity check.
208 + [[ ${PYPY_BINPKG_STORE} ]] || die 'PYPY_BINPKG_STORE unset, wtf?!'
209 + mkdir -p "${ROOT%/}${PYPY_BINPKG_STORE}" || die
210 + mv "${S}"/*.tar.xz "${ROOT%/}${PYPY_BINPKG_STORE}" || die
211 +}