summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dev-python/cython/cython-3.0.2-r1.ebuild86
-rw-r--r--dev-python/cython/files/cython-3.0.2-enummeta.patch69
2 files changed, 155 insertions, 0 deletions
diff --git a/dev-python/cython/cython-3.0.2-r1.ebuild b/dev-python/cython/cython-3.0.2-r1.ebuild
new file mode 100644
index 000000000000..444c115bf846
--- /dev/null
+++ b/dev-python/cython/cython-3.0.2-r1.ebuild
@@ -0,0 +1,86 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DISTUTILS_EXT=1
+DISTUTILS_USE_PEP517=setuptools
+PYTHON_TESTED=( python3_{10..11} )
+PYTHON_COMPAT=( "${PYTHON_TESTED[@]}" python3_12 pypy3 )
+PYTHON_REQ_USE="threads(+)"
+
+inherit distutils-r1 multiprocessing toolchain-funcs
+
+MY_P=${P/_rc/rc}
+DESCRIPTION="A Python to C compiler"
+HOMEPAGE="
+ https://cython.org/
+ https://github.com/cython/cython/
+ https://pypi.org/project/Cython/
+"
+SRC_URI="
+ https://github.com/cython/cython/archive/${PV/_rc/rc}.tar.gz
+ -> ${MY_P}.gh.tar.gz
+"
+S=${WORKDIR}/${MY_P}
+
+LICENSE="Apache-2.0"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~arm64-macos ~ppc-macos ~x64-macos ~x64-solaris"
+IUSE="test"
+RESTRICT="!test? ( test )"
+
+BDEPEND="
+ ${RDEPEND}
+ test? (
+ $(python_gen_cond_dep '
+ dev-python/numpy[${PYTHON_USEDEP}]
+ ' python3_{10..11})
+ )
+"
+
+PATCHES=(
+ "${FILESDIR}/${PN}-0.29.22-spawn-multiprocessing.patch"
+ "${FILESDIR}/${PN}-0.29.23-test_exceptions-py310.patch"
+ "${FILESDIR}/${PN}-0.29.23-pythran-parallel-install.patch"
+ # https://github.com/cython/cython/pull/5675
+ "${FILESDIR}/${P}-enummeta.patch"
+)
+
+distutils_enable_sphinx docs \
+ dev-python/jinja \
+ dev-python/sphinx-issues \
+ dev-python/sphinx-tabs
+
+python_compile() {
+ # Python gets confused when it is in sys.path before build.
+ local -x PYTHONPATH=
+
+ distutils-r1_python_compile
+}
+
+python_test() {
+ if ! has "${EPYTHON/./_}" "${PYTHON_TESTED[@]}"; then
+ einfo "Skipping tests on ${EPYTHON} (xfail)"
+ return
+ fi
+
+ # Needed to avoid confusing cache tests
+ unset CYTHON_FORCE_REGEN
+
+ tc-export CC
+ # https://github.com/cython/cython/issues/1911
+ local -x CFLAGS="${CFLAGS} -fno-strict-overflow"
+ "${PYTHON}" runtests.py \
+ -vv \
+ -j "$(makeopts_jobs)" \
+ --work-dir "${BUILD_DIR}"/tests \
+ --no-examples \
+ --no-code-style \
+ || die "Tests fail with ${EPYTHON}"
+}
+
+python_install_all() {
+ local DOCS=( CHANGES.rst README.rst ToDo.txt USAGE.txt )
+ distutils-r1_python_install_all
+}
diff --git a/dev-python/cython/files/cython-3.0.2-enummeta.patch b/dev-python/cython/files/cython-3.0.2-enummeta.patch
new file mode 100644
index 000000000000..284af4ac6c16
--- /dev/null
+++ b/dev-python/cython/files/cython-3.0.2-enummeta.patch
@@ -0,0 +1,69 @@
+From 81cc077ad035947a3429c245f1e28c8b43c6dcc6 Mon Sep 17 00:00:00 2001
+From: da-woods <dw-git@d-woods.co.uk>
+Date: Sat, 2 Sep 2023 10:32:59 +0100
+Subject: [PATCH] Fix invalid fastcall dict when keywords are passed
+
+Fixes #5665
+
+I'm slightly surprised this hasn't caused more bugs. We're passing
+a dict where we should be passing a tuple of names.
+
+Replacement should hopefully be right, but I don't know how
+optimized or otherwise it is.
+---
+ Cython/Utility/ObjectHandling.c | 36 +++++++++++++++++++--------------
+ 1 file changed, 21 insertions(+), 15 deletions(-)
+
+diff --git a/Cython/Utility/ObjectHandling.c b/Cython/Utility/ObjectHandling.c
+index 8ea5be42935..507fb94f605 100644
+--- a/Cython/Utility/ObjectHandling.c
++++ b/Cython/Utility/ObjectHandling.c
+@@ -2328,27 +2328,33 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObj
+ #endif
+ #endif
+
+- #if CYTHON_VECTORCALL
+- #if Py_VERSION_HEX < 0x03090000
+- vectorcallfunc f = _PyVectorcall_Function(func);
+- #else
+- vectorcallfunc f = PyVectorcall_Function(func);
+- #endif
+- if (f) {
+- return f(func, args, (size_t)nargs, kwargs);
+- }
+- #elif defined(__Pyx_CyFunction_USED) && CYTHON_BACKPORT_VECTORCALL
+- // exclude fused functions for now
+- if (__Pyx_CyFunction_CheckExact(func)) {
+- __pyx_vectorcallfunc f = __Pyx_CyFunction_func_vectorcall(func);
+- if (f) return f(func, args, (size_t)nargs, kwargs);
++ if (kwargs == NULL) {
++ #if CYTHON_VECTORCALL
++ #if Py_VERSION_HEX < 0x03090000
++ vectorcallfunc f = _PyVectorcall_Function(func);
++ #else
++ vectorcallfunc f = PyVectorcall_Function(func);
++ #endif
++ if (f) {
++ return f(func, args, (size_t)nargs, NULL);
++ }
++ #elif defined(__Pyx_CyFunction_USED) && CYTHON_BACKPORT_VECTORCALL
++ // exclude fused functions for now
++ if (__Pyx_CyFunction_CheckExact(func)) {
++ __pyx_vectorcallfunc f = __Pyx_CyFunction_func_vectorcall(func);
++ if (f) return f(func, args, (size_t)nargs, NULL);
++ }
++ #endif
+ }
+- #endif
+
+ if (nargs == 0) {
+ return __Pyx_PyObject_Call(func, $empty_tuple, kwargs);
+ }
++ #if PY_VERSION_HEX >= 0x03090000 && !CYTHON_COMPILING_IN_LIMITED_API
++ return PyObject_VectorcallDict(func, args, nargs, kwargs);
++ #else
+ return __Pyx_PyObject_FastCall_fallback(func, args, (size_t)nargs, kwargs);
++ #endif
+ }
+
+