Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-python/pypy3/files/, dev-python/pypy3/
Date: Sun, 20 Dec 2015 21:13:45
Message-Id: 1450646004.fd32d95f547b668b9d8fdddf36b35ce35a7edc77.mgorny@gentoo
1 commit: fd32d95f547b668b9d8fdddf36b35ce35a7edc77
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Sun Dec 20 21:12:42 2015 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Sun Dec 20 21:13:24 2015 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=fd32d95f
7
8 dev-python/pypy3: Add a live ebuild
9
10 dev-python/pypy3/files/2.5.0-shared-lib.patch | 12 ++
11 dev-python/pypy3/files/4.0.0-gentoo-path.patch | 50 ++++++
12 dev-python/pypy3/pypy3-9999.ebuild | 233 +++++++++++++++++++++++++
13 3 files changed, 295 insertions(+)
14
15 diff --git a/dev-python/pypy3/files/2.5.0-shared-lib.patch b/dev-python/pypy3/files/2.5.0-shared-lib.patch
16 new file mode 100644
17 index 0000000..ddd7473
18 --- /dev/null
19 +++ b/dev-python/pypy3/files/2.5.0-shared-lib.patch
20 @@ -0,0 +1,12 @@
21 +diff -ur pypy-2.5.0-src.orig/rpython/translator/platform/posix.py pypy-2.5.0-src/rpython/translator/platform/posix.py
22 +--- rpython/translator/platform/posix.py 2015-02-03 05:12:49.000000000 +0800
23 ++++ rpython/translator/platform/posix.py 2015-03-22 07:36:01.420116684 +0800
24 +@@ -183,7 +183,7 @@
25 + 'int main(int argc, char* argv[]) '
26 + '{ return $(PYPY_MAIN_FUNCTION)(argc, argv); }" > $@')
27 + m.rule('$(DEFAULT_TARGET)', ['$(TARGET)', 'main.o'],
28 +- '$(CC_LINK) $(LDFLAGS_LINK) main.o -L. -l$(SHARED_IMPORT_LIB) -o $@ $(RPATH_FLAGS)')
29 ++ '$(CC_LINK) $(LDFLAGS_LINK) main.o -L. -l$(SHARED_IMPORT_LIB) \'-Wl,-rpath,$$ORIGIN\' -o $@')
30 +
31 + return m
32 +
33
34 diff --git a/dev-python/pypy3/files/4.0.0-gentoo-path.patch b/dev-python/pypy3/files/4.0.0-gentoo-path.patch
35 new file mode 100644
36 index 0000000..1c0270d
37 --- /dev/null
38 +++ b/dev-python/pypy3/files/4.0.0-gentoo-path.patch
39 @@ -0,0 +1,50 @@
40 +From 165e05bbdc93e54411217c0198d0a5cbb9de4e33 Mon Sep 17 00:00:00 2001
41 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@g.o>
42 +Date: Fri, 27 Nov 2015 17:02:42 +0100
43 +Subject: [PATCH] Gentoo: override paths for system-wide install based on
44 + sys.prefix
45 +
46 +Override all default distutils install paths to ones suitable for
47 +system-wide install when sys.prefix indicates we're running the Gentoo
48 +system-wide install of PyPy with no prefix overrides (e.g. virtualenv).
49 +
50 +Fixes: https://bugs.gentoo.org/462306
51 +Fixes: https://bugs.gentoo.org/465546
52 +---
53 + lib-python/3/distutils/command/install.py | 13 ++++++++++++-
54 + 1 file changed, 12 insertions(+), 1 deletion(-)
55 +
56 +diff --git a/lib-python/3/distutils/command/install.py b/lib-python/3/distutils/command/install.py
57 +index fc43951..fed5218 100644
58 +--- a/lib-python/3/distutils/command/install.py
59 ++++ b/lib-python/3/distutils/command/install.py
60 +@@ -90,6 +90,13 @@ INSTALL_SCHEMES = {
61 + 'scripts': '$base/bin',
62 + 'data' : '$base',
63 + },
64 ++ 'gentoo': {
65 ++ 'purelib': '$base/site-packages',
66 ++ 'platlib': '$base/site-packages',
67 ++ 'headers': '$base/include',
68 ++ 'scripts': '@EPREFIX@/usr/bin',
69 ++ 'data' : '@EPREFIX@/usr',
70 ++ },
71 + }
72 +
73 + # The keys to an installation scheme; if any new types of files are to be
74 +@@ -476,7 +483,11 @@ class install (Command):
75 + # it's the caller's problem if they supply a bad name!
76 + if (hasattr(sys, 'pypy_version_info') and
77 + not name.endswith(('_user', '_home'))):
78 +- name = 'pypy'
79 ++ if self.install_base == os.path.normpath('@EPREFIX@/usr/@libdir@/pypy'):
80 ++ # override paths for system-wide install
81 ++ name = 'gentoo'
82 ++ else:
83 ++ name = 'pypy'
84 + scheme = INSTALL_SCHEMES[name]
85 + for key in SCHEME_KEYS:
86 + attrname = 'install_' + key
87 +--
88 +2.6.3
89 +
90
91 diff --git a/dev-python/pypy3/pypy3-9999.ebuild b/dev-python/pypy3/pypy3-9999.ebuild
92 new file mode 100644
93 index 0000000..a335b0f
94 --- /dev/null
95 +++ b/dev-python/pypy3/pypy3-9999.ebuild
96 @@ -0,0 +1,233 @@
97 +# Copyright 1999-2015 Gentoo Foundation
98 +# Distributed under the terms of the GNU General Public License v2
99 +# $Id$
100 +
101 +EAPI=5
102 +
103 +# pypy3 needs to be built using python 2
104 +PYTHON_COMPAT=( python2_7 pypy )
105 +EHG_PROJECT="pypy"
106 +EHG_REPO_URI="https://bitbucket.org/pypy/pypy"
107 +EHG_REVISION="py3k"
108 +inherit check-reqs eutils mercurial multilib multiprocessing pax-utils python-any-r1 toolchain-funcs versionator
109 +
110 +DESCRIPTION="A fast, compliant alternative implementation of the Python language"
111 +HOMEPAGE="http://pypy.org/"
112 +SRC_URI=""
113 +
114 +LICENSE="MIT"
115 +SLOT="0/$(get_version_component_range 1-2 ${PV})"
116 +KEYWORDS=""
117 +IUSE="bzip2 gdbm +jit low-memory ncurses sandbox shadowstack sqlite cpu_flags_x86_sse2 test tk"
118 +
119 +RDEPEND=">=sys-libs/zlib-1.1.3:0=
120 + virtual/libffi:0=
121 + virtual/libintl:0=
122 + dev-libs/expat:0=
123 + dev-libs/openssl:0=[-bindist]
124 + bzip2? ( app-arch/bzip2:0= )
125 + gdbm? ( sys-libs/gdbm:0= )
126 + ncurses? ( sys-libs/ncurses:0= )
127 + sqlite? ( dev-db/sqlite:3= )
128 + tk? (
129 + dev-lang/tk:0=
130 + dev-tcltk/tix:0=
131 + )
132 + !dev-python/pypy3-bin:0"
133 +DEPEND="${RDEPEND}
134 + low-memory? ( virtual/pypy:0 )
135 + !low-memory? ( ${PYTHON_DEPS} )"
136 +PDEPEND="app-admin/python-updater"
137 +
138 +S="${WORKDIR}/${P}-src"
139 +
140 +pkg_pretend() {
141 + if [[ ${MERGE_TYPE} != binary ]]; then
142 + if use low-memory; then
143 + CHECKREQS_MEMORY="1750M"
144 + use amd64 && CHECKREQS_MEMORY="3500M"
145 + else
146 + CHECKREQS_MEMORY="3G"
147 + use amd64 && CHECKREQS_MEMORY="6G"
148 + fi
149 +
150 + check-reqs_pkg_pretend
151 + fi
152 +}
153 +
154 +pkg_setup() {
155 + if [[ ${MERGE_TYPE} != binary ]]; then
156 + pkg_pretend
157 +
158 + # unset to allow forcing pypy below :)
159 + use low-memory && local EPYTHON=
160 + if python_is_installed pypy && [[ ! ${EPYTHON} || ${EPYTHON} == pypy ]]; then
161 + einfo "Using PyPy to perform the translation."
162 + local EPYTHON=pypy
163 + else
164 + einfo "Using ${EPYTHON:-python2} to perform the translation. Please note that upstream"
165 + einfo "recommends using PyPy for that. If you wish to do so, please install"
166 + einfo "virtual/pypy and ensure that EPYTHON variable is unset."
167 + fi
168 +
169 + python-any-r1_pkg_setup
170 + fi
171 +}
172 +
173 +src_unpack() {
174 + default
175 + mercurial_src_unpack
176 +}
177 +
178 +src_prepare() {
179 + epatch "${FILESDIR}/4.0.0-gentoo-path.patch" \
180 + "${FILESDIR}/1.9-distutils.unixccompiler.UnixCCompiler.runtime_library_dir_option.patch" \
181 + "${FILESDIR}"/2.5.0-shared-lib.patch # 517002
182 +
183 + sed -e "s^@EPREFIX@^${EPREFIX}^" \
184 + -e "s^@libdir@^$(get_libdir)^" \
185 + -i lib-python/3/distutils/command/install.py || die
186 +
187 + epatch_user
188 +}
189 +
190 +src_compile() {
191 + tc-export CC
192 +
193 + local jit_backend
194 + if use jit; then
195 + jit_backend='--jit-backend='
196 +
197 + # We only need the explicit sse2 switch for x86.
198 + # On other arches we can rely on autodetection which uses
199 + # compiler macros. Plus, --jit-backend= doesn't accept all
200 + # the modern values...
201 +
202 + if use x86; then
203 + if use cpu_flags_x86_sse2; then
204 + jit_backend+=x86
205 + else
206 + jit_backend+=x86-without-sse2
207 + fi
208 + else
209 + jit_backend+=auto
210 + fi
211 + fi
212 +
213 + local args=(
214 + --shared
215 + $(usex jit -Ojit -O2)
216 + $(usex shadowstack --gcrootfinder=shadowstack '')
217 + $(usex sandbox --sandbox '')
218 +
219 + ${jit_backend}
220 + --make-jobs=$(makeopts_jobs)
221 +
222 + pypy/goal/targetpypystandalone
223 + )
224 +
225 + # Avoid linking against libraries disabled by use flags
226 + local opts=(
227 + bzip2:bz2
228 + ncurses:_minimal_curses
229 + )
230 +
231 + local opt
232 + for opt in "${opts[@]}"; do
233 + local flag=${opt%:*}
234 + local mod=${opt#*:}
235 +
236 + args+=(
237 + $(usex ${flag} --withmod --withoutmod)-${mod}
238 + )
239 + done
240 +
241 + local interp=( "${PYTHON}" )
242 + if use low-memory; then
243 + interp=( env PYPY_GC_MAX_DELTA=200MB
244 + "${PYTHON}" --jit loop_longevity=300 )
245 + fi
246 +
247 + set -- "${interp[@]}" rpython/bin/rpython --batch "${args[@]}"
248 + echo -e "\033[1m${@}\033[0m"
249 + "${@}" || die "compile error"
250 +
251 + #use doc && emake -C pypy/doc/ html
252 + pax-mark m "${ED%/}${INSDESTTREE}/pypy-c"
253 +}
254 +
255 +src_install() {
256 + einfo "Installing PyPy ..."
257 + insinto "/usr/$(get_libdir)/pypy3"
258 + doins -r include lib_pypy lib-python pypy-c libpypy-c.so
259 + fperms a+x ${INSDESTTREE}/pypy-c ${INSDESTTREE}/libpypy-c.so
260 + pax-mark m "${ED%/}${INSDESTTREE}/pypy-c" "${ED%/}${INSDESTTREE}/libpypy-c.so"
261 + dosym ../$(get_libdir)/pypy3/pypy-c /usr/bin/pypy3
262 + dodoc README.rst
263 +
264 + if ! use gdbm; then
265 + rm -r "${ED%/}${INSDESTTREE}"/lib_pypy/gdbm.py \
266 + "${ED%/}${INSDESTTREE}"/lib-python/*3/test/test_gdbm.py || die
267 + fi
268 + if ! use sqlite; then
269 + rm -r "${ED%/}${INSDESTTREE}"/lib-python/*3/sqlite3 \
270 + "${ED%/}${INSDESTTREE}"/lib_pypy/_sqlite3.py \
271 + "${ED%/}${INSDESTTREE}"/lib-python/*3/test/test_sqlite.py || die
272 + fi
273 + if ! use tk; then
274 + rm -r "${ED%/}${INSDESTTREE}"/lib-python/*3/{idlelib,tkinter} \
275 + "${ED%/}${INSDESTTREE}"/lib_pypy/_tkinter \
276 + "${ED%/}${INSDESTTREE}"/lib-python/*3/test/test_{tcl,tk,ttk*}.py || die
277 + fi
278 +
279 + # Install docs
280 + #use doc && dohtml -r pypy/doc/_build/html/
281 +
282 + einfo "Generating caches and byte-compiling ..."
283 +
284 + local -x PYTHON=${ED%/}${INSDESTTREE}/pypy-c
285 + local -x LD_LIBRARY_PATH="${ED%/}${INSDESTTREE}"
286 + # we can't use eclass function since PyPy is dumb and always gives
287 + # paths relative to the interpreter
288 + local PYTHON_SITEDIR=${EPREFIX}/usr/$(get_libdir)/pypy3/site-packages
289 + python_export pypy3 EPYTHON
290 +
291 + echo "EPYTHON='${EPYTHON}'" > epython.py || die
292 + python_domodule epython.py
293 +
294 + # Generate Grammar and PatternGrammar pickles.
295 + "${PYTHON}" -c "import lib2to3.pygram, lib2to3.patcomp; lib2to3.patcomp.PatternCompiler()" \
296 + || die "Generation of Grammar and PatternGrammar pickles failed"
297 +
298 + # Generate cffi modules
299 + # Please keep in sync with pypy/tool/build_cffi_imports.py!
300 +#cffi_build_scripts = {
301 +# "sqlite3": "_sqlite3_build.py",
302 +# "audioop": "_audioop_build.py",
303 +# "tk": "_tkinter/tklib_build.py",
304 +# "curses": "_curses_build.py" if sys.platform != "win32" else None,
305 +# "syslog": "_syslog_build.py" if sys.platform != "win32" else None,
306 +# "gdbm": "_gdbm_build.py" if sys.platform != "win32" else None,
307 +# "pwdgrp": "_pwdgrp_build.py" if sys.platform != "win32" else None,
308 + cffi_targets=( audioop syslog pwdgrp )
309 + use gdbm && cffi_targets+=( gdbm )
310 + use ncurses && cffi_targets+=( curses )
311 + use sqlite && cffi_targets+=( sqlite3 )
312 + use tk && cffi_targets+=( tkinter/tklib )
313 +
314 + local t
315 + # all modules except tkinter output to .
316 + # tkinter outputs to the correct dir ...
317 + cd "${ED%/}${INSDESTTREE}"/lib_pypy || die
318 + for t in "${cffi_targets[@]}"; do
319 + # tkinter doesn't work via -m
320 + "${PYTHON}" "_${t}_build.py" || die "Failed to build CFFI bindings for ${t}"
321 + done
322 +
323 + # Cleanup temporary objects
324 + find "${ED%/}${INSDESTTREE}" -name "_cffi_*.[co]" -delete || die
325 + find "${ED%/}${INSDESTTREE}" -type d -empty -delete || die
326 +
327 + # compile the installed modules
328 + python_optimize "${ED%/}${INSDESTTREE}"
329 +}