1 |
commit: 24c7c0443888394fcce28b42d9c511edcbf9c52f |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Dec 20 21:11:35 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=24c7c044 |
7 |
|
8 |
dev-python/pypy: Add a live ebuild |
9 |
|
10 |
dev-python/pypy/pypy-9999.ebuild | 258 +++++++++++++++++++++++++++++++++++++++ |
11 |
1 file changed, 258 insertions(+) |
12 |
|
13 |
diff --git a/dev-python/pypy/pypy-9999.ebuild b/dev-python/pypy/pypy-9999.ebuild |
14 |
new file mode 100644 |
15 |
index 0000000..302e843 |
16 |
--- /dev/null |
17 |
+++ b/dev-python/pypy/pypy-9999.ebuild |
18 |
@@ -0,0 +1,258 @@ |
19 |
+# Copyright 1999-2015 Gentoo Foundation |
20 |
+# Distributed under the terms of the GNU General Public License v2 |
21 |
+# $Id$ |
22 |
+ |
23 |
+EAPI=5 |
24 |
+ |
25 |
+PYTHON_COMPAT=( python2_7 pypy ) |
26 |
+EHG_REPO_URI="https://bitbucket.org/pypy/pypy" |
27 |
+inherit check-reqs eutils mercurial multilib multiprocessing pax-utils python-any-r1 toolchain-funcs versionator |
28 |
+ |
29 |
+CPY_PATCHSET_VERSION="2.7.10-0" |
30 |
+ |
31 |
+DESCRIPTION="A fast, compliant alternative implementation of the Python language" |
32 |
+HOMEPAGE="http://pypy.org/" |
33 |
+SRC_URI=" |
34 |
+ https://dev.gentoo.org/~floppym/python/python-gentoo-patches-${CPY_PATCHSET_VERSION}.tar.xz" |
35 |
+ |
36 |
+LICENSE="MIT" |
37 |
+SLOT="0/$(get_version_component_range 1-2 ${PV})" |
38 |
+KEYWORDS="" |
39 |
+IUSE="bzip2 doc gdbm +jit low-memory ncurses sandbox shadowstack sqlite cpu_flags_x86_sse2 test tk" |
40 |
+ |
41 |
+RDEPEND=">=sys-libs/zlib-1.1.3:0= |
42 |
+ virtual/libffi:0= |
43 |
+ virtual/libintl:0= |
44 |
+ dev-libs/expat:0= |
45 |
+ dev-libs/openssl:0=[-bindist] |
46 |
+ bzip2? ( app-arch/bzip2:0= ) |
47 |
+ gdbm? ( sys-libs/gdbm:0= ) |
48 |
+ ncurses? ( sys-libs/ncurses:0= ) |
49 |
+ sqlite? ( dev-db/sqlite:3= ) |
50 |
+ tk? ( |
51 |
+ dev-lang/tk:0= |
52 |
+ dev-tcltk/tix:0= |
53 |
+ ) |
54 |
+ !dev-python/pypy-bin:0" |
55 |
+DEPEND="${RDEPEND} |
56 |
+ doc? ( dev-python/sphinx ) |
57 |
+ ${PYTHON_DEPS} |
58 |
+ test? ( dev-python/pytest )" |
59 |
+PDEPEND="app-admin/python-updater" |
60 |
+ |
61 |
+S="${WORKDIR}/${P}-src" |
62 |
+ |
63 |
+pkg_pretend() { |
64 |
+ if [[ ${MERGE_TYPE} != binary ]]; then |
65 |
+ if use low-memory; then |
66 |
+ if ! python_is_installed pypy; then |
67 |
+ eerror "USE=low-memory requires a (possibly old) version of dev-python/pypy" |
68 |
+ eerror "or dev-python/pypy-bin being installed. Please install it using e.g.:" |
69 |
+ eerror |
70 |
+ eerror " $ emerge -1v dev-python/pypy-bin" |
71 |
+ eerror |
72 |
+ eerror "before attempting to build dev-python/pypy[low-memory]." |
73 |
+ die "dev-python/pypy-bin (or dev-python/pypy) needs to be installed for USE=low-memory" |
74 |
+ fi |
75 |
+ |
76 |
+ CHECKREQS_MEMORY="1750M" |
77 |
+ use amd64 && CHECKREQS_MEMORY="3500M" |
78 |
+ else |
79 |
+ CHECKREQS_MEMORY="3G" |
80 |
+ use amd64 && CHECKREQS_MEMORY="6G" |
81 |
+ fi |
82 |
+ |
83 |
+ check-reqs_pkg_pretend |
84 |
+ fi |
85 |
+} |
86 |
+ |
87 |
+pkg_setup() { |
88 |
+ if [[ ${MERGE_TYPE} != binary ]]; then |
89 |
+ pkg_pretend |
90 |
+ |
91 |
+ if python_is_installed pypy; then |
92 |
+ if [[ ! ${EPYTHON} || ${EPYTHON} == pypy ]] || use low-memory; then |
93 |
+ einfo "Using already-installed PyPy to perform the translation." |
94 |
+ local EPYTHON=pypy |
95 |
+ else |
96 |
+ einfo "Using ${EPYTHON} to perform the translation. Please note that upstream" |
97 |
+ einfo "recommends using PyPy for that. If you wish to do so, please unset" |
98 |
+ einfo "the EPYTHON variable." |
99 |
+ fi |
100 |
+ fi |
101 |
+ |
102 |
+ python-any-r1_pkg_setup |
103 |
+ fi |
104 |
+} |
105 |
+ |
106 |
+src_unpack() { |
107 |
+ default |
108 |
+ mercurial_src_unpack |
109 |
+} |
110 |
+ |
111 |
+src_prepare() { |
112 |
+ epatch "${FILESDIR}/4.0.0-gentoo-path.patch" \ |
113 |
+ "${FILESDIR}/1.9-distutils.unixccompiler.UnixCCompiler.runtime_library_dir_option.patch" \ |
114 |
+ "${FILESDIR}"/2.5.0-shared-lib.patch # 517002 |
115 |
+ |
116 |
+ sed -e "s^@EPREFIX@^${EPREFIX}^" \ |
117 |
+ -e "s^@libdir@^$(get_libdir)^" \ |
118 |
+ -i lib-python/2.7/distutils/command/install.py || die |
119 |
+ |
120 |
+ # apply CPython stdlib patches |
121 |
+ pushd lib-python/2.7 > /dev/null || die |
122 |
+ epatch "${FILESDIR}"/2.5.0_all_distutils_cxx.patch \ |
123 |
+ "${WORKDIR}"/patches/22_all_turkish_locale.patch \ |
124 |
+ "${WORKDIR}"/patches/62_all_xml.use_pyxml.patch |
125 |
+ popd > /dev/null || die |
126 |
+ |
127 |
+ epatch_user |
128 |
+} |
129 |
+ |
130 |
+src_compile() { |
131 |
+ tc-export CC |
132 |
+ |
133 |
+ local jit_backend |
134 |
+ if use jit; then |
135 |
+ jit_backend='--jit-backend=' |
136 |
+ |
137 |
+ # We only need the explicit sse2 switch for x86. |
138 |
+ # On other arches we can rely on autodetection which uses |
139 |
+ # compiler macros. Plus, --jit-backend= doesn't accept all |
140 |
+ # the modern values... |
141 |
+ |
142 |
+ if use x86; then |
143 |
+ if use cpu_flags_x86_sse2; then |
144 |
+ jit_backend+=x86 |
145 |
+ else |
146 |
+ jit_backend+=x86-without-sse2 |
147 |
+ fi |
148 |
+ else |
149 |
+ jit_backend+=auto |
150 |
+ fi |
151 |
+ fi |
152 |
+ |
153 |
+ local args=( |
154 |
+ --shared |
155 |
+ $(usex jit -Ojit -O2) |
156 |
+ $(usex shadowstack --gcrootfinder=shadowstack '') |
157 |
+ $(usex sandbox --sandbox '') |
158 |
+ |
159 |
+ ${jit_backend} |
160 |
+ --make-jobs=$(makeopts_jobs) |
161 |
+ |
162 |
+ pypy/goal/targetpypystandalone |
163 |
+ ) |
164 |
+ |
165 |
+ # Avoid linking against libraries disabled by use flags |
166 |
+ local opts=( |
167 |
+ bzip2:bz2 |
168 |
+ ncurses:_minimal_curses |
169 |
+ ) |
170 |
+ |
171 |
+ local opt |
172 |
+ for opt in "${opts[@]}"; do |
173 |
+ local flag=${opt%:*} |
174 |
+ local mod=${opt#*:} |
175 |
+ |
176 |
+ args+=( |
177 |
+ $(usex ${flag} --withmod --withoutmod)-${mod} |
178 |
+ ) |
179 |
+ done |
180 |
+ |
181 |
+ local interp=( "${PYTHON}" ) |
182 |
+ if use low-memory; then |
183 |
+ interp=( env PYPY_GC_MAX_DELTA=200MB |
184 |
+ "${PYTHON}" --jit loop_longevity=300 ) |
185 |
+ fi |
186 |
+ |
187 |
+ set -- "${interp[@]}" rpython/bin/rpython --batch "${args[@]}" |
188 |
+ echo -e "\033[1m${@}\033[0m" |
189 |
+ "${@}" || die "compile error" |
190 |
+ |
191 |
+ use doc && emake -C pypy/doc/ html |
192 |
+ pax-mark m "${ED%/}${INSDESTTREE}/pypy-c" |
193 |
+} |
194 |
+ |
195 |
+src_test() { |
196 |
+ # (unset) |
197 |
+ local -x PYTHONDONTWRITEBYTECODE |
198 |
+ |
199 |
+ ./pypy-c ./pypy/test_all.py --pypy=./pypy-c lib-python || die |
200 |
+} |
201 |
+ |
202 |
+src_install() { |
203 |
+ einfo "Installing PyPy ..." |
204 |
+ insinto "/usr/$(get_libdir)/pypy" |
205 |
+ doins -r include lib_pypy lib-python pypy-c libpypy-c.so |
206 |
+ fperms a+x ${INSDESTTREE}/pypy-c ${INSDESTTREE}/libpypy-c.so |
207 |
+ pax-mark m "${ED%/}${INSDESTTREE}/pypy-c" "${ED%/}${INSDESTTREE}/libpypy-c.so" |
208 |
+ dosym ../$(get_libdir)/pypy/pypy-c /usr/bin/pypy |
209 |
+ dodoc README.rst |
210 |
+ |
211 |
+ if ! use gdbm; then |
212 |
+ rm -r "${ED%/}${INSDESTTREE}"/lib_pypy/gdbm.py \ |
213 |
+ "${ED%/}${INSDESTTREE}"/lib-python/*2.7/test/test_gdbm.py || die |
214 |
+ fi |
215 |
+ if ! use sqlite; then |
216 |
+ rm -r "${ED%/}${INSDESTTREE}"/lib-python/*2.7/sqlite3 \ |
217 |
+ "${ED%/}${INSDESTTREE}"/lib_pypy/_sqlite3.py \ |
218 |
+ "${ED%/}${INSDESTTREE}"/lib-python/*2.7/test/test_sqlite.py || die |
219 |
+ fi |
220 |
+ if ! use tk; then |
221 |
+ rm -r "${ED%/}${INSDESTTREE}"/lib-python/*2.7/{idlelib,lib-tk} \ |
222 |
+ "${ED%/}${INSDESTTREE}"/lib_pypy/_tkinter \ |
223 |
+ "${ED%/}${INSDESTTREE}"/lib-python/*2.7/test/test_{tcl,tk,ttk*}.py || die |
224 |
+ fi |
225 |
+ |
226 |
+ # Install docs |
227 |
+ use doc && dohtml -r pypy/doc/_build/html/ |
228 |
+ |
229 |
+ einfo "Generating caches and byte-compiling ..." |
230 |
+ |
231 |
+ local -x PYTHON=${ED%/}${INSDESTTREE}/pypy-c |
232 |
+ local -x LD_LIBRARY_PATH="${ED%/}${INSDESTTREE}" |
233 |
+ # we can't use eclass function since PyPy is dumb and always gives |
234 |
+ # paths relative to the interpreter |
235 |
+ local PYTHON_SITEDIR=${EPREFIX}/usr/$(get_libdir)/pypy/site-packages |
236 |
+ python_export pypy EPYTHON |
237 |
+ |
238 |
+ echo "EPYTHON='${EPYTHON}'" > epython.py || die |
239 |
+ python_domodule epython.py |
240 |
+ |
241 |
+ # Generate Grammar and PatternGrammar pickles. |
242 |
+ "${PYTHON}" -c "import lib2to3.pygram, lib2to3.patcomp; lib2to3.patcomp.PatternCompiler()" \ |
243 |
+ || die "Generation of Grammar and PatternGrammar pickles failed" |
244 |
+ |
245 |
+ # Generate cffi modules |
246 |
+ # Please keep in sync with pypy/tool/build_cffi_imports.py! |
247 |
+#cffi_build_scripts = { |
248 |
+# "sqlite3": "_sqlite3_build.py", |
249 |
+# "audioop": "_audioop_build.py", |
250 |
+# "tk": "_tkinter/tklib_build.py", |
251 |
+# "curses": "_curses_build.py" if sys.platform != "win32" else None, |
252 |
+# "syslog": "_syslog_build.py" if sys.platform != "win32" else None, |
253 |
+# "gdbm": "_gdbm_build.py" if sys.platform != "win32" else None, |
254 |
+# "pwdgrp": "_pwdgrp_build.py" if sys.platform != "win32" else None, |
255 |
+ cffi_targets=( audioop syslog pwdgrp ) |
256 |
+ use gdbm && cffi_targets+=( gdbm ) |
257 |
+ use ncurses && cffi_targets+=( curses ) |
258 |
+ use sqlite && cffi_targets+=( sqlite3 ) |
259 |
+ use tk && cffi_targets+=( tkinter/tklib ) |
260 |
+ |
261 |
+ local t |
262 |
+ # all modules except tkinter output to . |
263 |
+ # tkinter outputs to the correct dir ... |
264 |
+ cd "${ED%/}${INSDESTTREE}"/lib_pypy || die |
265 |
+ for t in "${cffi_targets[@]}"; do |
266 |
+ # tkinter doesn't work via -m |
267 |
+ "${PYTHON}" "_${t}_build.py" || die "Failed to build CFFI bindings for ${t}" |
268 |
+ done |
269 |
+ |
270 |
+ # Cleanup temporary objects |
271 |
+ find "${ED%/}${INSDESTTREE}" -name "_cffi_*.[co]" -delete || die |
272 |
+ find "${ED%/}${INSDESTTREE}" -type d -empty -delete || die |
273 |
+ |
274 |
+ # compile the installed modules |
275 |
+ python_optimize "${ED%/}${INSDESTTREE}" |
276 |
+} |