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/
Date: Tue, 17 May 2022 07:49:26
Message-Id: 1652773757.972df7506fdf616e2b923ad4ce44f86a607efb5c.mgorny@gentoo
1 commit: 972df7506fdf616e2b923ad4ce44f86a607efb5c
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Tue May 17 07:47:53 2022 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Tue May 17 07:49:17 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=972df750
7
8 dev-python/pypy3: Backport OpenSSL 3 fixes as 7.3.9_p1
9
10 Closes: https://bugs.gentoo.org/844148
11 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
12
13 dev-python/pypy3/Manifest | 1 +
14 dev-python/pypy3/pypy3-7.3.9_p1.ebuild | 200 +++++++++++++++++++++++++++++++++
15 2 files changed, 201 insertions(+)
16
17 diff --git a/dev-python/pypy3/Manifest b/dev-python/pypy3/Manifest
18 index c5caa42dac85..7a8135fddca1 100644
19 --- a/dev-python/pypy3/Manifest
20 +++ b/dev-python/pypy3/Manifest
21 @@ -1,2 +1,3 @@
22 DIST pypy3.9-gentoo-patches-7.3.9.tar.xz 1564 BLAKE2B fe0875ef002842a78fb31589f6d0b255c3dea10f2bd014231ae9b17641f65f810ac84fe7961de1a4614249b0166f2127c3aa37947f7d1d4c85860a31b89110f1 SHA512 a1dc3ee36e908e29b2bbbb100a97b7910bd4325c5dc55c0455cdca450d6b272d1463708b383e0607e9499b1932da4442f97d2da57e47ed3a4ff8fd3c78a54732
23 +DIST pypy3.9-gentoo-patches-7.3.9_p1.tar.xz 3952 BLAKE2B 20ff145749d24f15214c0c78f3fdc5e1cdbfc307972ad9dbc03f1b9704b25ea962434aee0d58a882912374b45f726eb449f0abafd663bddf14867807951b0a7f SHA512 3ce7a126fb7c52754d3b65e3df0786c80a98522ce78ab44fd5f81cd84a41e8b5929df2d8e4f644ed6c2265ca5da397cd7f37d44944cd08f7c8ae1cc8a2fd7e0d
24 DIST pypy3.9-v7.3.9-src.tar.bz2 26976726 BLAKE2B bf1ed21c575901abac020120aaff07ab57f1404713211b19cbd1eb4d6ffc675b7933be8c6fffc2b69ab467963d6598534cd5aa90c02feddad596611d2a6b6581 SHA512 83f8a6a2da351c190d2d224242cbc35e35529c7a8e8d842eaf5c945cbce2e172b02a340f32af3d49df8d5288370d794d5bc95fc12dd4a13d817c925abf06198a
25
26 diff --git a/dev-python/pypy3/pypy3-7.3.9_p1.ebuild b/dev-python/pypy3/pypy3-7.3.9_p1.ebuild
27 new file mode 100644
28 index 000000000000..536c3974f232
29 --- /dev/null
30 +++ b/dev-python/pypy3/pypy3-7.3.9_p1.ebuild
31 @@ -0,0 +1,200 @@
32 +# Copyright 1999-2022 Gentoo Authors
33 +# Distributed under the terms of the GNU General Public License v2
34 +
35 +EAPI=8
36 +
37 +PYTHON_COMPAT=( python2_7 )
38 +inherit pax-utils python-any-r1 toolchain-funcs
39 +
40 +PYPY_PV=${PV%_p*}
41 +MY_P=pypy3.9-v${PYPY_PV/_rc/rc}
42 +PATCHSET="pypy3.9-gentoo-patches-${PV/_rc/rc}"
43 +
44 +DESCRIPTION="A fast, compliant alternative implementation of the Python (3.9) language"
45 +HOMEPAGE="https://www.pypy.org/"
46 +SRC_URI="
47 + https://buildbot.pypy.org/pypy/${MY_P}-src.tar.bz2
48 + https://dev.gentoo.org/~mgorny/dist/python/${PATCHSET}.tar.xz
49 +"
50 +S="${WORKDIR}/${MY_P}-src"
51 +
52 +LICENSE="MIT"
53 +# pypy3 -c 'import sysconfig; print(sysconfig.get_config_var("SOABI"))'
54 +# also check pypy/interpreter/pycode.py -> pypy_incremental_magic
55 +SLOT="0/pypy39-pp73"
56 +KEYWORDS="~amd64 ~arm64 ~ppc64 ~x86 ~amd64-linux ~x86-linux"
57 +IUSE="bzip2 gdbm +jit ncurses sqlite test tk"
58 +# many tests are failing upstream
59 +# see https://buildbot.pypy.org/summary?branch=py3.9
60 +RESTRICT="test"
61 +
62 +RDEPEND="
63 + || (
64 + >=dev-python/pypy3-exe-${PYPY_PV}:3.9-${PYPY_PV}[bzip2?,ncurses?]
65 + >=dev-python/pypy3-exe-bin-${PYPY_PV}:3.9-${PYPY_PV}
66 + )
67 + dev-lang/python-exec[python_targets_pypy3(-)]
68 + dev-libs/openssl:0=
69 + gdbm? ( sys-libs/gdbm:0= )
70 + sqlite? ( dev-db/sqlite:3= )
71 + tk? (
72 + dev-lang/tk:0=
73 + dev-tcltk/tix:0=
74 + )
75 + !<dev-python/pypy3-bin-7.3.0:0
76 +"
77 +DEPEND="
78 + ${RDEPEND}
79 + test? (
80 + ${PYTHON_DEPS}
81 + !!dev-python/pytest-forked
82 + )
83 +"
84 +
85 +pkg_setup() {
86 + use test && python-any-r1_pkg_setup
87 +}
88 +
89 +src_prepare() {
90 + local PATCHES=(
91 + "${WORKDIR}/${PATCHSET}"
92 + )
93 + default
94 +
95 + eapply_user
96 +}
97 +
98 +src_configure() {
99 + tc-export CC
100 +}
101 +
102 +src_compile() {
103 + mkdir bin || die
104 + # switch to the layout expected for cffi module builds
105 + mkdir include/pypy3.9 || die
106 + # copy over to make sys.prefix happy
107 + cp -p "${BROOT}"/usr/bin/pypy3.9-c-${PYPY_PV} pypy3.9-c || die
108 + cp -p "${BROOT}"/usr/include/pypy3.9/${PYPY_PV}/* include/pypy3.9/ || die
109 + # (not installed by pypy-exe)
110 + rm pypy/module/cpyext/include/_numpypy/numpy/README || die
111 + mv pypy/module/cpyext/include/* include/pypy3.9/ || die
112 + mv pypy/module/cpyext/parse/*.h include/pypy3.9/ || die
113 + pax-mark m pypy3.9-c
114 +
115 + # verify the subslot
116 + local soabi=$(
117 + ./pypy3.9-c - <<-EOF
118 + import sysconfig
119 + print(sysconfig.get_config_var("SOABI"))
120 + EOF
121 + )
122 + [[ ${soabi} == ${SLOT#*/} ]] || die "update subslot to ${soabi}"
123 +
124 + einfo "Generating caches and CFFI modules ..."
125 +
126 + # Generate Grammar and PatternGrammar pickles.
127 + ./pypy3.9-c - <<-EOF || die "Generation of Grammar and PatternGrammar pickles failed"
128 + import lib2to3.pygram
129 + import lib2to3.patcomp
130 + lib2to3.patcomp.PatternCompiler()
131 + EOF
132 +
133 + # Generate cffi modules
134 + # Please keep in sync with pypy/tool/build_cffi_imports.py!
135 + # (NB: we build CFFI modules first to avoid error log when importing
136 + # build_cffi_imports).
137 + cffi_targets=( pypy_util blake2/_blake2 sha3/_sha3 ssl
138 + audioop syslog pwdgrp resource lzma posixshmem )
139 + use gdbm && cffi_targets+=( gdbm )
140 + use ncurses && cffi_targets+=( curses )
141 + use sqlite && cffi_targets+=( sqlite3 )
142 + use tk && cffi_targets+=( tkinter/tklib )
143 +
144 + local t
145 + # all modules except tkinter output to .
146 + # tkinter outputs to the correct dir ...
147 + cd lib_pypy || die
148 + for t in "${cffi_targets[@]}"; do
149 + # tkinter doesn't work via -m
150 + ../pypy3.9-c "_${t}_build.py" || die "Failed to build CFFI bindings for ${t}"
151 + done
152 +
153 + # Verify that CFFI module list is up-to-date
154 + local expected_cksum=63d4659f
155 + local local_cksum=$(
156 + ../pypy3.9-c - <<-EOF
157 + import binascii
158 + import json
159 + from pypy_tools.build_cffi_imports import cffi_build_scripts as x
160 + print("%08x" % (binascii.crc32(json.dumps(x).encode()),))
161 + EOF
162 + )
163 + if [[ ${local_cksum} != ${expected_cksum} ]]; then
164 + die "Please verify cffi_targets and update checksum to ${local_cksum}"
165 + fi
166 +
167 + # Cleanup temporary objects
168 + find -name "*_cffi.[co]" -delete || die
169 + find -type d -empty -delete || die
170 +}
171 +
172 +src_test() {
173 + # (unset)
174 + local -x PYTHONDONTWRITEBYTECODE=
175 + local -x COLUMNS=80
176 +
177 + # Test runner requires Python 2 too. However, it spawns PyPy3
178 + # internally so that we end up testing the correct interpreter.
179 + # (--deselect for failing doctests)
180 + "${EPYTHON}" ./pypy/test_all.py --pypy=./pypy3.9-c -vv lib-python || die
181 +}
182 +
183 +src_install() {
184 + einfo "Installing PyPy ..."
185 + dodir /usr/bin
186 + dosym pypy3.9-c-${PYPY_PV} /usr/bin/pypy3.9
187 + dosym pypy3.9 /usr/bin/pypy3
188 + insinto /usr/lib/pypy3.9
189 + # preserve mtimes to avoid obsoleting caches
190 + insopts -p
191 + doins -r lib-python/3/. lib_pypy/.
192 + insinto /usr/include
193 + doins -r include/pypy3.9
194 +
195 + # replace copied headers with symlinks
196 + for x in "${BROOT}"/usr/include/pypy3.9/${PYPY_PV}/*; do
197 + dosym "${PYPY_PV}/${x##*/}" "/usr/include/pypy3.9/${x##*/}"
198 + done
199 +
200 + dodoc README.rst
201 +
202 + local dest=/usr/lib/pypy3.9
203 + if ! use gdbm; then
204 + rm -r "${ED}${dest}"/_gdbm* || die
205 + fi
206 + if ! use sqlite; then
207 + rm -r "${ED}${dest}"/sqlite3 \
208 + "${ED}${dest}"/_sqlite3* \
209 + "${ED}${dest}"/test/test_sqlite.py || die
210 + fi
211 + if ! use tk; then
212 + rm -r "${ED}${dest}"/{idlelib,tkinter} \
213 + "${ED}${dest}"/_tkinter \
214 + "${ED}${dest}"/test/test_{tcl,tk,ttk*}.py || die
215 + fi
216 +
217 + local -x EPYTHON=pypy3
218 + local -x PYTHON=${ED}/usr/bin/pypy3.9-c-${PYPY_PV}
219 + # temporarily copy to build tree to facilitate module builds
220 + cp -p "${BROOT}/usr/bin/pypy3.9-c-${PYPY_PV}" "${PYTHON}" || die
221 +
222 + echo "EPYTHON='${EPYTHON}'" > epython.py || die
223 + python_moduleinto "${dest}"/site-packages
224 + python_domodule epython.py
225 +
226 + einfo "Byte-compiling Python standard library..."
227 + python_optimize "${ED}${dest}"
228 +
229 + # remove to avoid collisions
230 + rm "${PYTHON}" || die
231 +}