summaryrefslogtreecommitdiff
path: root/dev-python/pypy-exe
diff options
context:
space:
mode:
Diffstat (limited to 'dev-python/pypy-exe')
-rw-r--r--dev-python/pypy-exe/Manifest2
-rw-r--r--dev-python/pypy-exe/pypy-exe-8.0.0.ebuild188
2 files changed, 190 insertions, 0 deletions
diff --git a/dev-python/pypy-exe/Manifest b/dev-python/pypy-exe/Manifest
index 156812a602b7..d7b6e227312e 100644
--- a/dev-python/pypy-exe/Manifest
+++ b/dev-python/pypy-exe/Manifest
@@ -1,2 +1,4 @@
DIST pypy2.7-gentoo-patches-7.3.23.tar.xz 5316 BLAKE2B 923494c49ef09b1929ba1986891a08f23e4343c44eac792a688ac88b48d21770101ca50fcdf3986c686adefb24fbf58aef674ec608feea775984ab8a16385cb6 SHA512 c1d07caef19b77cb4950d56c1de8079900fc21728061f8620210932d2cd85f701407ce7b9947d2ef044211d1ffe8b77ce445da3c5aef69321b45e7ab8550dee3
+DIST pypy2.7-gentoo-patches-8.0.0.tar.xz 988 BLAKE2B 6bd236da38a45c50891758f6446fa70c81358141b8904062d2d1e27a7a938ee970c592108a081c8e9c83c869415b235e0202eae93ccf8d050866567976ed1fcd SHA512 a365d070448374777e7b2a7f5f7226e7ade89fd427c44b01f1cd8acaa215095de91a85321f9ca8283d04ed1d9aeaa5d191f5b2e33e44a831e38912d56a7a970e
DIST pypy2.7-v7.3.23-src.tar.bz2 21023543 BLAKE2B 7638e5aecd30d9c2c9ab22b1ab9a43331685885ee90ebfda8d2a88da34e4b0b998bd967eed30b309110b9d40b14df75f24a7e9219c7383b542602869ee1a12d9 SHA512 3750fc9c5309baa7627d00a77b4b2b1e0d755b75841acd0fcee484bc332f1e9ed9c1f33d2f4800777f20ea8849356f39c84167f96b9ebfdd7e479798d62eac06
+DIST pypy2.7-v8.0.0-src.tar.gz 21312909 BLAKE2B 5ee9800c5399b1af82fde2f729fc63f6523e345b070176c4c13c9bd2cc0537baa6d04875042d4bd96ecec0c3bc5e8e79c08add1443b9c99ae40d396b91178ef7 SHA512 e0ae52034b5e03d413c47e1ddd9a7bde3549c70b4519c1630367c314ebce58638af78d5936c89943de1907477eb4bec8c149d850836991af14a50c9e643dfa63
diff --git a/dev-python/pypy-exe/pypy-exe-8.0.0.ebuild b/dev-python/pypy-exe/pypy-exe-8.0.0.ebuild
new file mode 100644
index 000000000000..77ba4bc812df
--- /dev/null
+++ b/dev-python/pypy-exe/pypy-exe-8.0.0.ebuild
@@ -0,0 +1,188 @@
+# Copyright 1999-2026 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit check-reqs pax-utils toolchain-funcs
+
+PYVER=2.7
+PYPY_PV=${PV%_p*}
+
+MY_P=pypy${PYVER}-v${PYPY_PV/_}
+PATCHSET="pypy${PYVER}-gentoo-patches-${PV/_}"
+
+DESCRIPTION="PyPy executable (build from source)"
+HOMEPAGE="
+ https://pypy.org/
+ https://github.com/pypy/pypy/
+"
+SRC_URI="
+ https://downloads.python.org/pypy/${MY_P}-src.tar.gz
+ https://distfiles.gentoo.org/pub/proj/python/patchsets/pypy${PYVER}/${PATCHSET}.tar.xz
+"
+S="${WORKDIR}/${MY_P}-src"
+
+LICENSE="MIT"
+SLOT="${PYPY_PV}"
+KEYWORDS="~amd64 ~arm64 ~ppc64 ~x86"
+IUSE="bzip2 +jit low-memory ncurses cpu_flags_x86_sse2"
+
+DEPEND="
+ >=virtual/zlib-1.1.3:=
+ dev-libs/libffi:0=
+ virtual/libintl:0=
+ dev-libs/expat:0=
+ bzip2? ( app-arch/bzip2:0= )
+ ncurses? ( sys-libs/ncurses:0= )
+"
+RDEPEND="
+ ${DEPEND}
+ !dev-python/pypy-exe-bin:${PYPY_PV}
+"
+# don't enforce the dep on dev-python/pypy with USE=low-memory
+# since it's going to cause circular dep with unhelpful error message
+BDEPEND="
+ !low-memory? (
+ || (
+ dev-lang/pypy:2.7
+ dev-python/pypy
+ dev-lang/python:2.7
+ )
+ )
+"
+
+check_env() {
+ if ! has_version -b dev-lang/pypy:2.7 &&
+ ! has_version -b dev-python/pypy
+ then
+ if use low-memory; then
+ eerror "USE=low-memory requires (a prior version of) dev-python/pypy"
+ eerror "installed."
+ else
+ ewarn "CPython 2.7 will be used to perform the translation. Upstream"
+ ewarn "recommends using (a prior version of) dev-python/pypy instead."
+ fi
+ elog "You can install a prebuilt version of PyPy first using e.g.:"
+ elog " $ emerge -1v dev-python/pypy dev-python/pypy-exe-bin"
+
+ if use low-memory; then
+ die "dev-python/pypy needs to be installed for USE=low-memory"
+ fi
+ fi
+
+ if use low-memory; then
+ CHECKREQS_MEMORY="1750M"
+ use amd64 && CHECKREQS_MEMORY="3500M"
+ else
+ CHECKREQS_MEMORY="3G"
+ use amd64 && CHECKREQS_MEMORY="6G"
+ fi
+
+ check-reqs_pkg_pretend
+}
+
+pkg_pretend() {
+ [[ ${MERGE_TYPE} != binary ]] && check_env
+}
+
+pkg_setup() {
+ [[ ${MERGE_TYPE} != binary ]] && check_env
+}
+
+src_prepare() {
+ local PATCHES=(
+ "${WORKDIR}/${PATCHSET}"
+ )
+ default
+}
+
+src_configure() {
+ tc-export CC
+
+ local jit_backend
+ if use jit; then
+ jit_backend='--jit-backend='
+
+ # We only need the explicit sse2 switch for x86.
+ # On other arches we can rely on autodetection which uses
+ # compiler macros. Plus, --jit-backend= doesn't accept all
+ # the modern values...
+
+ if use x86; then
+ if use cpu_flags_x86_sse2; then
+ jit_backend+=x86
+ else
+ jit_backend+=x86-without-sse2
+ fi
+ else
+ jit_backend+=auto
+ fi
+ fi
+
+ local args=(
+ --no-shared
+ $(usex jit -Ojit -O2)
+
+ ${jit_backend}
+
+ pypy/goal/targetpypystandalone
+ )
+
+ # Avoid linking against libraries disabled by use flags
+ local opts=(
+ bzip2:bz2
+ ncurses:_minimal_curses
+ )
+
+ local opt
+ for opt in "${opts[@]}"; do
+ local flag=${opt%:*}
+ local mod=${opt#*:}
+
+ args+=(
+ $(usex ${flag} --withmod --withoutmod)-${mod}
+ )
+ done
+
+ local interp
+ if use low-memory ||
+ has_version -b dev-lang/pypy:2.7 ||
+ has_version -b dev-python/pypy
+ then
+ einfo "Using already-installed PyPy to perform the translation."
+ interp=( pypy )
+ if use low-memory; then
+ local -x PYPY_GC_MAX_DELTA=200MB
+ interp+=( --jit loop_longevity=300 )
+ fi
+ else
+ einfo "Using CPython 2.7 to perform the translation."
+ interp=( python2.7 )
+
+ # reuse bundled pycparser to avoid external dep
+ mkdir -p "${T}"/pymod/cffi || die
+ : > "${T}"/pymod/cffi/__init__.py || die
+ cp -r lib_pypy/cffi/_pycparser "${T}"/pymod/cffi/ || die
+ local -x PYTHONPATH=${T}/pymod:${PYTHONPATH}
+ fi
+
+ # translate into the C sources
+ # we're going to build them ourselves since otherwise pypy does not
+ # free up the unneeded memory before spawning the compiler
+ set -- "${interp[@]}" rpython/bin/rpython --batch --source "${args[@]}"
+ echo -e "\033[1m${@}\033[0m"
+ "${@}" || die "translation failed"
+}
+
+src_compile() {
+ emake -C "${T}"/usession*-0/testing_1
+}
+
+src_install() {
+ local dest=/usr/lib/pypy${PYVER}
+ exeinto "${dest}"
+ newexe "${T}"/usession*-0/testing_1/pypy-c pypy-c-${PYPY_PV}
+ insinto "${dest}"/include/${PYPY_PV}
+ doins include/pypy_*
+ pax-mark m "${ED}${dest}/pypy-c-${PYPY_PV}"
+}