public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] repo/gentoo:master commit in: dev-python/cffi/, dev-python/cffi/files/
@ 2023-04-03  6:40 Sam James
  0 siblings, 0 replies; 4+ messages in thread
From: Sam James @ 2023-04-03  6:40 UTC (permalink / raw
  To: gentoo-commits

commit:     bdac487a18df8385251bac0d45433f1a8dc8ceb4
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Mon Apr  3 06:39:26 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Apr  3 06:39:52 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=bdac487a

dev-python/cffi: backport HPPA fix

Signed-off-by: Sam James <sam <AT> gentoo.org>

 dev-python/cffi/cffi-1.15.1-r1.ebuild        | 65 ++++++++++++++++++++++++++++
 dev-python/cffi/files/cffi-1.15.1-hppa.patch | 59 +++++++++++++++++++++++++
 2 files changed, 124 insertions(+)

diff --git a/dev-python/cffi/cffi-1.15.1-r1.ebuild b/dev-python/cffi/cffi-1.15.1-r1.ebuild
new file mode 100644
index 000000000000..fc58f4f7e3fb
--- /dev/null
+++ b/dev-python/cffi/cffi-1.15.1-r1.ebuild
@@ -0,0 +1,65 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# please keep this ebuild at EAPI 7 -- sys-apps/portage dep
+EAPI=7
+
+DISTUTILS_USE_PEP517=setuptools
+# DO NOT ADD pypy to PYTHON_COMPAT
+# pypy bundles a modified version of cffi. Use python_gen_cond_dep instead.
+PYTHON_COMPAT=( python3_{9..11} )
+
+inherit distutils-r1 toolchain-funcs pypi
+
+DESCRIPTION="Foreign Function Interface for Python calling C code"
+HOMEPAGE="
+	https://cffi.readthedocs.io/
+	https://pypi.org/project/cffi/
+"
+
+LICENSE="MIT"
+SLOT="0/${PV}"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
+
+DEPEND="
+	dev-libs/libffi:=
+"
+RDEPEND="
+	${DEPEND}
+	dev-python/pycparser[${PYTHON_USEDEP}]
+"
+BDEPEND="
+	${RDEPEND}
+	virtual/pkgconfig
+"
+
+distutils_enable_sphinx doc/source
+distutils_enable_tests pytest
+
+PATCHES=(
+	"${FILESDIR}"/cffi-1.14.0-darwin-no-brew.patch
+	"${FILESDIR}"/${P}-hppa.patch
+)
+
+src_prepare() {
+	if [[ ${CHOST} == *darwin* ]] ; then
+		# Don't obsessively try to find libffi
+		sed -i -e "s/.*\-iwithsysroot\/usr\/include\/ffi.*/\tpass/" setup.py || die
+	fi
+	distutils-r1_src_prepare
+}
+
+src_configure() {
+	tc-export PKG_CONFIG
+}
+
+python_test() {
+	local EPYTEST_IGNORE=(
+		# these tests call pip
+		testing/cffi0/test_zintegration.py
+	)
+
+	"${EPYTHON}" -c "import _cffi_backend as backend" || die
+	local -x PYTEST_DISABLE_PLUGIN_AUTOLOAD=1
+	epytest c testing
+}

diff --git a/dev-python/cffi/files/cffi-1.15.1-hppa.patch b/dev-python/cffi/files/cffi-1.15.1-hppa.patch
new file mode 100644
index 000000000000..e185e7b93929
--- /dev/null
+++ b/dev-python/cffi/files/cffi-1.15.1-hppa.patch
@@ -0,0 +1,59 @@
+https://foss.heptapod.net/pypy/cffi/-/commit/ab11bfa551697cd2b61fdaa571c7975c06e6912c
+
+From ab11bfa551697cd2b61fdaa571c7975c06e6912c Mon Sep 17 00:00:00 2001
+From: John David Anglin <dave.anglin@bell.net>
+Date: Sun, 18 Dec 2022 14:52:04 -0500
+Subject: [PATCH] Fix the test failures on hppa
+
+A couple of years ago the libffi port for hppa-linux was changed from using a
+trampoline executed on the stack to the function descriptor technique used by
+ia64. This doesn't require an executable stack and is simpler. However,
+function pointers need to have the PLABEL bit set in the pointer. As a result,
+a simple cast can't be used to convert closure pointers to function pointers.
+
+python-cffi uses its own closure allocation so the problem can't be fixed in
+libffi.
+
+I added a macro CFFI_FN to do the conversion. It shouldn't affect other
+architectures. There is a similar define in libffi.
+
+Fixes: https://bugs.debian.org/1024271
+
+--HG--
+branch : hppa
+--- a/c/_cffi_backend.c
++++ b/c/_cffi_backend.c
+@@ -60,6 +60,13 @@
+ # endif
+ #endif
+ 
++/* Convert from closure pointer to function pointer. */
++#if defined(__hppa__) && !defined(__LP64__)
++#define CFFI_FN(f) ((void (*)(void))((unsigned int)(f) | 2))
++#else
++#define CFFI_FN(f) ((void (*)(void))f)
++#endif
++
+ 
+ /* Define the following macro ONLY if you trust libffi's version of
+  * ffi_closure_alloc() more than the code in malloc_closure.h.
+@@ -3191,7 +3198,7 @@ cdata_call(CDataObject *cd, PyObject *args, PyObject *kwds)
+ 
+     Py_BEGIN_ALLOW_THREADS
+     restore_errno();
+-    ffi_call(&cif_descr->cif, (void (*)(void))(cd->c_data),
++    ffi_call(&cif_descr->cif, (void (*)(void)) CFFI_FN(cd->c_data),
+              resultdata, buffer_array);
+     save_errno();
+     Py_END_ALLOW_THREADS
+@@ -6394,7 +6401,7 @@ static PyObject *b_callback(PyObject *self, PyObject *args)
+         goto error;
+     Py_INCREF(ct);
+     cd->head.c_type = ct;
+-    cd->head.c_data = (char *)closure_exec;
++    cd->head.c_data = (char *)CFFI_FN(closure_exec);
+     cd->head.c_weakreflist = NULL;
+     closure->user_data = NULL;
+     cd->closure = closure;
+-- 
+GitLab


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: dev-python/cffi/, dev-python/cffi/files/
@ 2023-04-05  1:18 Sam James
  0 siblings, 0 replies; 4+ messages in thread
From: Sam James @ 2023-04-05  1:18 UTC (permalink / raw
  To: gentoo-commits

commit:     eb99a6b05973202d0597295ebc2b4b246f28ea7c
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Apr  5 00:56:04 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Apr  5 00:56:23 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=eb99a6b0

dev-python/cffi: fix tests w/ python3.11

This actually *did* work when 3.11 was added to the ebuild but upstream (cpython)
made a last-minute change so it ended up breaking later.

Signed-off-by: Sam James <sam <AT> gentoo.org>

 dev-python/cffi/cffi-1.15.1-r1.ebuild              |  1 +
 .../cffi/files/cffi-1.15.1-python3.11-tests.patch  | 90 ++++++++++++++++++++++
 2 files changed, 91 insertions(+)

diff --git a/dev-python/cffi/cffi-1.15.1-r1.ebuild b/dev-python/cffi/cffi-1.15.1-r1.ebuild
index fc58f4f7e3fb..192186933382 100644
--- a/dev-python/cffi/cffi-1.15.1-r1.ebuild
+++ b/dev-python/cffi/cffi-1.15.1-r1.ebuild
@@ -39,6 +39,7 @@ distutils_enable_tests pytest
 PATCHES=(
 	"${FILESDIR}"/cffi-1.14.0-darwin-no-brew.patch
 	"${FILESDIR}"/${P}-hppa.patch
+	"${FILESDIR}"/${P}-python3.11-tests.patch
 )
 
 src_prepare() {

diff --git a/dev-python/cffi/files/cffi-1.15.1-python3.11-tests.patch b/dev-python/cffi/files/cffi-1.15.1-python3.11-tests.patch
new file mode 100644
index 000000000000..e3be1c247877
--- /dev/null
+++ b/dev-python/cffi/files/cffi-1.15.1-python3.11-tests.patch
@@ -0,0 +1,90 @@
+https://foss.heptapod.net/pypy/cffi/-/commit/8a3c2c816d789639b49d3ae867213393ed7abdff
+
+From 8a3c2c816d789639b49d3ae867213393ed7abdff Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
+Date: Fri, 15 Jul 2022 16:11:37 +0200
+Subject: [PATCH] Adjust tests for a last minute Python 3.11 change in the
+ traceback format
+
+See https://github.com/python/cpython/issues/93883
+and https://github.com/python/cpython/pull/93994
+
+--HG--
+branch : python3.11.0b4
+--- a/c/test_c.py
++++ b/c/test_c.py
+@@ -1342,11 +1342,11 @@ def test_callback_exception():
+     except ImportError:
+         import io as cStringIO    # Python 3
+     import linecache
+-    def matches(istr, ipattern, ipattern38, ipattern311):
++    def matches(istr, ipattern, ipattern38, ipattern311=None):
+         if sys.version_info >= (3, 8):
+             ipattern = ipattern38
+         if sys.version_info >= (3, 11):
+-            ipattern = ipattern311
++            ipattern = ipattern311 or ipattern38
+         str, pattern = istr, ipattern
+         while '$' in pattern:
+             i = pattern.index('$')
+@@ -1400,16 +1400,6 @@ Traceback (most recent call last):
+   File "$", line $, in check_value
+     $
+ ValueError: 42
+-""", """\
+-Exception ignored from cffi callback <function$Zcb1 at 0x$>:
+-Traceback (most recent call last):
+-  File "$", line $, in Zcb1
+-    $
+-    $
+-  File "$", line $, in check_value
+-    $
+-    $
+-ValueError: 42
+ """)
+         sys.stderr = cStringIO.StringIO()
+         bigvalue = 20000
+@@ -1424,13 +1414,6 @@ Traceback (most recent call last):
+   File "$", line $, in test_callback_exception
+     $
+ OverflowError: integer 60000 does not fit 'short'
+-""", """\
+-Exception ignored from cffi callback <function$Zcb1 at 0x$>, trying to convert the result back to C:
+-Traceback (most recent call last):
+-  File "$", line $, in test_callback_exception
+-    $
+-    $
+-OverflowError: integer 60000 does not fit 'short'
+ """)
+         sys.stderr = cStringIO.StringIO()
+         bigvalue = 20000
+@@ -1479,19 +1462,6 @@ Traceback (most recent call last):
+   File "$", line $, in test_callback_exception
+     $
+ TypeError: $integer$
+-""", """\
+-Exception ignored from cffi callback <function$Zcb1 at 0x$>, trying to convert the result back to C:
+-Traceback (most recent call last):
+-  File "$", line $, in test_callback_exception
+-    $
+-    $
+-OverflowError: integer 60000 does not fit 'short'
+-Exception ignored during handling of the above exception by 'onerror':
+-Traceback (most recent call last):
+-  File "$", line $, in test_callback_exception
+-    $
+-    $
+-TypeError: $integer$
+ """)
+         #
+         sys.stderr = cStringIO.StringIO()
+@@ -1526,7 +1496,6 @@ Exception ignored from cffi callback <function$Zcb1 at 0x$>, trying to convert t
+ Traceback (most recent call last):
+   File "$", line $, in test_callback_exception
+     $
+-    $
+ OverflowError: integer 60000 does not fit 'short'
+ Exception ignored during handling of the above exception by 'onerror':
+ Traceback (most recent call last):
+-- 
+GitLab


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: dev-python/cffi/, dev-python/cffi/files/
@ 2023-05-27 13:21 Michał Górny
  0 siblings, 0 replies; 4+ messages in thread
From: Michał Górny @ 2023-05-27 13:21 UTC (permalink / raw
  To: gentoo-commits

commit:     9b3a682c2cfe38d7749781f1c72abb2df87243dd
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat May 27 10:41:38 2023 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat May 27 13:20:42 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9b3a682c

dev-python/cffi: Enable experimental py3.12 support

Add a patch that fixes the most important py3.12 issues, and enable it
in order to facilitate testing packages.

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 dev-python/cffi/cffi-1.15.1-r3.ebuild         |  81 +++++++++
 dev-python/cffi/files/cffi-1.15.1-py312.patch | 247 ++++++++++++++++++++++++++
 2 files changed, 328 insertions(+)

diff --git a/dev-python/cffi/cffi-1.15.1-r3.ebuild b/dev-python/cffi/cffi-1.15.1-r3.ebuild
new file mode 100644
index 000000000000..6c093945c628
--- /dev/null
+++ b/dev-python/cffi/cffi-1.15.1-r3.ebuild
@@ -0,0 +1,81 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# please keep this ebuild at EAPI 8 -- sys-apps/portage dep
+EAPI=8
+
+# py3.12 support is experimental, expect problems in revdeps
+DISTUTILS_EXT=1
+DISTUTILS_USE_PEP517=setuptools
+# DO NOT ADD pypy to PYTHON_COMPAT
+# pypy bundles a modified version of cffi. Use python_gen_cond_dep instead.
+PYTHON_COMPAT=( python3_{10..12} )
+
+inherit distutils-r1 toolchain-funcs pypi
+
+DESCRIPTION="Foreign Function Interface for Python calling C code"
+HOMEPAGE="
+	https://cffi.readthedocs.io/
+	https://pypi.org/project/cffi/
+"
+SRC_URI+=" https://dev.gentoo.org/~sam/distfiles/${CATEGORY}/${PN}/${P}-drop-deprecated-py.patch.xz"
+
+LICENSE="MIT"
+SLOT="0/${PV}"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris"
+
+# Needs recent libffi for HPPA fixes
+DEPEND="
+	>=dev-libs/libffi-3.4.4-r1:=
+"
+# setuptools as a modern distutils provider
+RDEPEND="
+	${DEPEND}
+	dev-python/pycparser[${PYTHON_USEDEP}]
+	dev-python/setuptools[${PYTHON_USEDEP}]
+"
+BDEPEND="
+	${RDEPEND}
+	virtual/pkgconfig
+"
+
+distutils_enable_sphinx doc/source
+distutils_enable_tests pytest
+
+PATCHES=(
+	"${FILESDIR}"/cffi-1.14.0-darwin-no-brew.patch
+	"${FILESDIR}"/${P}-hppa.patch
+	"${FILESDIR}"/${P}-python3.11-tests.patch
+	"${WORKDIR}"/${P}-drop-deprecated-py.patch
+	"${FILESDIR}"/${P}-py312.patch
+)
+
+src_prepare() {
+	if [[ ${CHOST} == *darwin* ]] ; then
+		# Don't obsessively try to find libffi
+		sed -i -e "s/.*\-iwithsysroot\/usr\/include\/ffi.*/\tpass/" setup.py || die
+	fi
+	distutils-r1_src_prepare
+}
+
+src_configure() {
+	tc-export PKG_CONFIG
+}
+
+python_test() {
+	local EPYTEST_IGNORE=(
+		# these tests call pip
+		testing/cffi0/test_zintegration.py
+	)
+	local EPYTEST_DESELECT=()
+	if [[ ${EPYTHON} == python3.12 ]]; then
+		EPYTEST_DESELECT+=(
+			# TODO: these tests hang
+			testing/embedding
+		)
+	fi
+
+	"${EPYTHON}" -c "import _cffi_backend as backend" || die
+	local -x PYTEST_DISABLE_PLUGIN_AUTOLOAD=1
+	epytest c testing
+}

diff --git a/dev-python/cffi/files/cffi-1.15.1-py312.patch b/dev-python/cffi/files/cffi-1.15.1-py312.patch
new file mode 100644
index 000000000000..a5477d686dd7
--- /dev/null
+++ b/dev-python/cffi/files/cffi-1.15.1-py312.patch
@@ -0,0 +1,247 @@
+diff -r 79b97f01064f cffi/vengine_cpy.py
+--- a/cffi/vengine_cpy.py	Thu Feb 23 05:42:01 2023 +0100
++++ b/cffi/vengine_cpy.py	Sat May 27 11:03:01 2023 +0200
+@@ -1,10 +1,16 @@
+ #
+ # DEPRECATED: implementation for ffi.verify()
+ #
+-import sys, imp
++import sys
+ from . import model
+ from .error import VerificationError
+ 
++if sys.version_info >= (3, 12):
++    import importlib.machinery
++    import importlib.util
++else:
++    import imp
++
+ 
+ class VCPythonEngine(object):
+     _class_key = 'x'
+@@ -20,16 +26,22 @@
+         pass
+ 
+     def find_module(self, module_name, path, so_suffixes):
+-        try:
+-            f, filename, descr = imp.find_module(module_name, path)
+-        except ImportError:
+-            return None
+-        if f is not None:
+-            f.close()
++        if sys.version_info >= (3, 12):
++            spec = importlib.machinery.PathFinder.find_spec(module_name, path)
++            if spec is None:
++                return None
++            filename = spec.origin
++        else:
++            try:
++                f, filename, descr = imp.find_module(module_name, path)
++            except ImportError:
++                return None
++            if f is not None:
++                f.close()
+         # Note that after a setuptools installation, there are both .py
+         # and .so files with the same basename.  The code here relies on
+         # imp.find_module() locating the .so in priority.
+-        if descr[0] not in so_suffixes:
++        if not filename.endswith(tuple(so_suffixes)):
+             return None
+         return filename
+ 
+@@ -145,15 +157,23 @@
+     def load_library(self, flags=None):
+         # XXX review all usages of 'self' here!
+         # import it as a new extension module
+-        imp.acquire_lock()
++        if sys.version_info < (3, 12):
++            imp.acquire_lock()
+         try:
+             if hasattr(sys, "getdlopenflags"):
+                 previous_flags = sys.getdlopenflags()
+             try:
+                 if hasattr(sys, "setdlopenflags") and flags is not None:
+                     sys.setdlopenflags(flags)
+-                module = imp.load_dynamic(self.verifier.get_module_name(),
+-                                          self.verifier.modulefilename)
++                if sys.version_info >= (3, 12):
++                    spec = importlib.util.spec_from_file_location(
++                        self.verifier.get_module_name(),
++                        self.verifier.modulefilename)
++                    module = importlib.util.module_from_spec(spec)
++                    spec.loader.exec_module(module)
++                else:
++                    module = imp.load_dynamic(self.verifier.get_module_name(),
++                                              self.verifier.modulefilename)
+             except ImportError as e:
+                 error = "importing %r: %s" % (self.verifier.modulefilename, e)
+                 raise VerificationError(error)
+@@ -161,7 +181,8 @@
+                 if hasattr(sys, "setdlopenflags"):
+                     sys.setdlopenflags(previous_flags)
+         finally:
+-            imp.release_lock()
++            if sys.version_info < (3, 12):
++                imp.release_lock()
+         #
+         # call loading_cpy_struct() to get the struct layout inferred by
+         # the C compiler
+diff -r 79b97f01064f testing/cffi0/test_verify.py
+--- a/testing/cffi0/test_verify.py	Thu Feb 23 05:42:01 2023 +0100
++++ b/testing/cffi0/test_verify.py	Sat May 27 11:03:01 2023 +0200
+@@ -1575,10 +1575,16 @@
+ def test_callback_in_thread():
+     if sys.platform == 'win32':
+         pytest.skip("pthread only")
+-    import os, subprocess, imp
++    import os, subprocess
+     arg = os.path.join(os.path.dirname(__file__), 'callback_in_thread.py')
+-    g = subprocess.Popen([sys.executable, arg,
+-                          os.path.dirname(imp.find_module('cffi')[1])])
++    if sys.version_info >= (3, 12):
++        import importlib.util
++        spec = importlib.util.find_spec('cffi')
++        cffi_path = os.path.dirname(spec.origin)
++    else:
++        import imp
++        cffi_path = imp.find_module('cffi')[1]
++    g = subprocess.Popen([sys.executable, arg, os.path.dirname(cffi_path)])
+     result = g.wait()
+     assert result == 0
+ 
+diff -r 79b97f01064f testing/cffi0/test_zdistutils.py
+--- a/testing/cffi0/test_zdistutils.py	Thu Feb 23 05:42:01 2023 +0100
++++ b/testing/cffi0/test_zdistutils.py	Sat May 27 11:03:01 2023 +0200
+@@ -1,8 +1,9 @@
+-import sys, os, imp, math, shutil
++import sys, os, math, shutil
+ import pytest
+ from cffi import FFI, FFIError
+ from cffi.verifier import Verifier, _locate_engine_class, _get_so_suffixes
+ from cffi.ffiplatform import maybe_relative_path
++from testing.support import load_dynamic
+ from testing.udir import udir
+ 
+ 
+@@ -80,7 +81,7 @@
+         v.compile_module()
+         assert v.get_module_name().startswith('_cffi_')
+         if v.generates_python_module():
+-            mod = imp.load_dynamic(v.get_module_name(), v.modulefilename)
++            mod = load_dynamic(v.get_module_name(), v.modulefilename)
+             assert hasattr(mod, '_cffi_setup')
+ 
+     def test_compile_module_explicit_filename(self):
+@@ -95,7 +96,7 @@
+         assert filename == v.modulefilename
+         assert v.get_module_name() == basename
+         if v.generates_python_module():
+-            mod = imp.load_dynamic(v.get_module_name(), v.modulefilename)
++            mod = load_dynamic(v.get_module_name(), v.modulefilename)
+             assert hasattr(mod, '_cffi_setup')
+ 
+     def test_name_from_checksum_of_cdef(self):
+diff -r 79b97f01064f testing/cffi1/test_new_ffi_1.py
+--- a/testing/cffi1/test_new_ffi_1.py	Thu Feb 23 05:42:01 2023 +0100
++++ b/testing/cffi1/test_new_ffi_1.py	Sat May 27 11:03:01 2023 +0200
+@@ -1,5 +1,5 @@
+ import pytest
+-import platform, imp
++import platform
+ import sys, os, ctypes
+ import cffi
+ from testing.udir import udir
+@@ -91,7 +91,7 @@
+ 
+     outputfilename = recompile(ffi1, "test_new_ffi_1", CCODE,
+                                tmpdir=str(udir))
+-    module = imp.load_dynamic("test_new_ffi_1", outputfilename)
++    module = load_dynamic("test_new_ffi_1", outputfilename)
+     ffi = module.ffi
+     construction_params = (ffi1, CCODE)
+ 
+@@ -1619,8 +1619,8 @@
+         ffi2 = cffi.FFI(); ffi2.cdef(CDEF2)
+         outputfilename = recompile(ffi2, "test_multiple_independent_structs",
+                                    CDEF2, tmpdir=str(udir))
+-        module = imp.load_dynamic("test_multiple_independent_structs",
+-                                  outputfilename)
++        module = load_dynamic("test_multiple_independent_structs",
++                              outputfilename)
+         ffi1 = module.ffi
+         foo1 = ffi1.new("struct ab *", [10])
+         foo2 = ffi .new("struct ab *", [20, 30])
+@@ -1635,8 +1635,8 @@
+         outputfilename = recompile(ffi2,
+                                    "test_include_struct_union_enum_typedef",
+                                    CCODE, tmpdir=str(udir))
+-        module = imp.load_dynamic("test_include_struct_union_enum_typedef",
+-                                  outputfilename)
++        module = load_dynamic("test_include_struct_union_enum_typedef",
++                              outputfilename)
+         ffi2 = module.ffi
+         #
+         p = ffi2.new("struct nonpacked *", [b'A', -43141])
+@@ -1783,7 +1783,7 @@
+                                    "int myfunc(int x) { return x + 1; }\n"
+                                    "int myvar = -5;\n"
+                                    "#define MYFOO 42", tmpdir=str(udir))
+-        imp.load_dynamic("_test_import_from_lib", outputfilename)
++        load_dynamic("_test_import_from_lib", outputfilename)
+         from _test_import_from_lib.lib import myfunc, myvar, MYFOO
+         assert MYFOO == 42
+         assert myfunc(43) == 44
+diff -r 79b97f01064f testing/support.py
+--- a/testing/support.py	Thu Feb 23 05:42:01 2023 +0100
++++ b/testing/support.py	Sat May 27 11:03:01 2023 +0200
+@@ -1,5 +1,11 @@
+ import sys, os
+ 
++if sys.version_info >= (3, 12):
++    import importlib.util
++else:
++    import imp
++
++
+ if sys.version_info < (3,):
+     __all__ = ['u', 'arraytostring']
+ 
+@@ -16,7 +22,7 @@
+         return a.tostring()
+ 
+ else:
+-    __all__ = ['u', 'unicode', 'long', 'arraytostring']
++    __all__ = ['u', 'unicode', 'long', 'arraytostring', 'load_dynamic']
+     u = ""
+     unicode = str
+     long = int
+@@ -71,15 +77,27 @@
+     def getvalue(self):
+         return self._value
+ 
++
++def load_dynamic(module_name, outputfilename):
++    if sys.version_info >= (3, 12):
++        import importlib.util
++        spec = importlib.util.spec_from_file_location(module_name,
++                                                      outputfilename)
++        module = importlib.util.module_from_spec(spec)
++        spec.loader.exec_module(module)
++        return module
++    else:
++        return imp.load_dynamic(module_name, outputfilename)
++
++
+ def _verify(ffi, module_name, preamble, *args, **kwds):
+-    import imp
+     from cffi.recompiler import recompile
+     from .udir import udir
+     assert module_name not in sys.modules, "module name conflict: %r" % (
+         module_name,)
+     kwds.setdefault('tmpdir', str(udir))
+     outputfilename = recompile(ffi, module_name, preamble, *args, **kwds)
+-    module = imp.load_dynamic(module_name, outputfilename)
++    module = load_dynamic(module_name, outputfilename)
+     #
+     # hack hack hack: copy all *bound methods* from module.ffi back to the
+     # ffi instance.  Then calls like ffi.new() will invoke module.ffi.new().


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: dev-python/cffi/, dev-python/cffi/files/
@ 2023-10-28 18:24 Michał Górny
  0 siblings, 0 replies; 4+ messages in thread
From: Michał Górny @ 2023-10-28 18:24 UTC (permalink / raw
  To: gentoo-commits

commit:     8c9b985317df50c6904ec35a53ffec230366f7c6
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Oct 28 18:05:42 2023 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Oct 28 18:24:34 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8c9b9853

dev-python/cffi: Remove old

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 dev-python/cffi/Manifest                           |   3 -
 dev-python/cffi/cffi-1.15.1-r3.ebuild              |  84 -------
 dev-python/cffi/cffi-1.16.0_rc2.ebuild             |  72 ------
 dev-python/cffi/files/cffi-1.15.1-hppa.patch       |  59 -----
 dev-python/cffi/files/cffi-1.15.1-py312.patch      | 247 ---------------------
 .../cffi/files/cffi-1.15.1-python3.11-tests.patch  |  90 --------
 6 files changed, 555 deletions(-)

diff --git a/dev-python/cffi/Manifest b/dev-python/cffi/Manifest
index 3a68a6468cbc..de8f69ee1c67 100644
--- a/dev-python/cffi/Manifest
+++ b/dev-python/cffi/Manifest
@@ -1,4 +1 @@
-DIST cffi-1.15.1-drop-deprecated-py.patch.xz 31244 BLAKE2B 7c8a6ca1166335fbd385de35ebb636f21049a4dd9c52171ec58da08a61dc64c271b4afa2d69bf8b877a8c9747dfae6a8529615bbed69f5a8ab30ba5fc99c61f4 SHA512 9aba4b172b070a1a1719de2c35667abe4c7b27208b8ca3ecbf90bf168ed694f4524154e69fada5ff6f141a94b8a438db16239ba353fa9914b318b77e41dfd920
-DIST cffi-1.15.1.tar.gz 508501 BLAKE2B accc317385d9af7dbed3397afde63fbab63bfc935376d951802055c63796863ed102a940f192789924480b9b16751c8cf3d21caf9b262c479c61ffc977aac83c SHA512 e99cafcb029076abc29e435b490fa0573ee2856f4051b7ca8a5b38cd125d56dd9dae8b189f59ceb3d728a675da8ee83239e09e19f8b0feeddea4b186ab5173a5
 DIST cffi-1.16.0.tar.gz 512873 BLAKE2B 9e8d107b3124a072e559c4a536b54a172e90f9fe51d8184dacc2914a8ffa84f2682eee9c90401325dfb0f36f3f8ea0456afc93e2b85a4fef5f07ae4475e0a76b SHA512 fd2588115092202aa9289c9d4e0a0b3e264b5e9ec1dc192950f31aeb412fd9f9d4e5c96a3f9c6762987b58ccc1e229f2012ddda89211797104df672d8ed51152
-DIST cffi-1.16.0rc2.tar.gz 512927 BLAKE2B 5bb3f9728971a113d0c939bf4127bf541eaed3730486e9b4ba57432fa8c626d7688166f431db090a1248c2d3ddeaeee18fdf940dc08d7a4d3b7fda18d2d99861 SHA512 39d0a13a1f05b8f7f2d697e2324396f34588eabf226f6de5bf50a4931671827148ed25cb2f8003d0d3f4882580d71e6e1f485a63b964dd85e17c9e8b268213e6

diff --git a/dev-python/cffi/cffi-1.15.1-r3.ebuild b/dev-python/cffi/cffi-1.15.1-r3.ebuild
deleted file mode 100644
index 84db58f7f227..000000000000
--- a/dev-python/cffi/cffi-1.15.1-r3.ebuild
+++ /dev/null
@@ -1,84 +0,0 @@
-# Copyright 1999-2023 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-# please keep this ebuild at EAPI 8 -- sys-apps/portage dep
-EAPI=8
-
-# py3.12 support is experimental, expect problems in revdeps
-DISTUTILS_EXT=1
-DISTUTILS_USE_PEP517=setuptools
-# DO NOT ADD pypy to PYTHON_COMPAT
-# pypy bundles a modified version of cffi. Use python_gen_cond_dep instead.
-PYTHON_COMPAT=( python3_{10..12} )
-
-inherit distutils-r1 toolchain-funcs pypi
-
-DESCRIPTION="Foreign Function Interface for Python calling C code"
-HOMEPAGE="
-	https://cffi.readthedocs.io/
-	https://pypi.org/project/cffi/
-"
-SRC_URI+=" https://dev.gentoo.org/~sam/distfiles/${CATEGORY}/${PN}/${P}-drop-deprecated-py.patch.xz"
-
-LICENSE="MIT"
-SLOT="0/${PV}"
-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"
-
-# Needs recent libffi for HPPA fixes
-DEPEND="
-	>=dev-libs/libffi-3.4.4-r1:=
-"
-# setuptools as a modern distutils provider
-RDEPEND="
-	${DEPEND}
-	dev-python/pycparser[${PYTHON_USEDEP}]
-	dev-python/setuptools[${PYTHON_USEDEP}]
-"
-BDEPEND="
-	${RDEPEND}
-	virtual/pkgconfig
-	test? (
-		dev-python/py[${PYTHON_USEDEP}]
-	)
-"
-
-distutils_enable_sphinx doc/source
-distutils_enable_tests pytest
-
-PATCHES=(
-	"${FILESDIR}"/cffi-1.14.0-darwin-no-brew.patch
-	"${FILESDIR}"/${P}-hppa.patch
-	"${FILESDIR}"/${P}-python3.11-tests.patch
-	"${WORKDIR}"/${P}-drop-deprecated-py.patch
-	"${FILESDIR}"/${P}-py312.patch
-)
-
-src_prepare() {
-	if [[ ${CHOST} == *darwin* ]] ; then
-		# Don't obsessively try to find libffi
-		sed -i -e "s/.*\-iwithsysroot\/usr\/include\/ffi.*/\tpass/" setup.py || die
-	fi
-	distutils-r1_src_prepare
-}
-
-src_configure() {
-	tc-export PKG_CONFIG
-}
-
-python_test() {
-	local EPYTEST_IGNORE=(
-		# these tests call pip
-		testing/cffi0/test_zintegration.py
-	)
-	local EPYTEST_DESELECT=()
-	if [[ ${EPYTHON} == python3.12 ]]; then
-		EPYTEST_DESELECT+=(
-			# TODO: these tests hang
-			testing/embedding
-		)
-	fi
-
-	"${EPYTHON}" -c "import _cffi_backend as backend" || die
-	local -x PYTEST_DISABLE_PLUGIN_AUTOLOAD=1
-	epytest c testing
-}

diff --git a/dev-python/cffi/cffi-1.16.0_rc2.ebuild b/dev-python/cffi/cffi-1.16.0_rc2.ebuild
deleted file mode 100644
index 8269ab390919..000000000000
--- a/dev-python/cffi/cffi-1.16.0_rc2.ebuild
+++ /dev/null
@@ -1,72 +0,0 @@
-# Copyright 1999-2023 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-# please keep this ebuild at EAPI 8 -- sys-apps/portage dep
-EAPI=8
-
-# py3.12 support is experimental, expect problems in revdeps
-DISTUTILS_EXT=1
-DISTUTILS_USE_PEP517=setuptools
-# DO NOT ADD pypy to PYTHON_COMPAT
-# pypy bundles a modified version of cffi. Use python_gen_cond_dep instead.
-PYTHON_COMPAT=( python3_{10..12} )
-
-inherit distutils-r1 toolchain-funcs pypi
-
-DESCRIPTION="Foreign Function Interface for Python calling C code"
-HOMEPAGE="
-	https://cffi.readthedocs.io/
-	https://pypi.org/project/cffi/
-"
-
-LICENSE="MIT"
-SLOT="0/${PV}"
-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"
-
-# Needs recent libffi for HPPA fixes
-DEPEND="
-	>=dev-libs/libffi-3.4.4-r1:=
-"
-# setuptools as a modern distutils provider
-RDEPEND="
-	${DEPEND}
-	dev-python/pycparser[${PYTHON_USEDEP}]
-	dev-python/setuptools[${PYTHON_USEDEP}]
-"
-BDEPEND="
-	${RDEPEND}
-	virtual/pkgconfig
-	test? (
-		dev-python/py[${PYTHON_USEDEP}]
-	)
-"
-
-distutils_enable_sphinx doc/source
-distutils_enable_tests pytest
-
-PATCHES=(
-	"${FILESDIR}"/cffi-1.14.0-darwin-no-brew.patch
-)
-
-src_prepare() {
-	if [[ ${CHOST} == *darwin* ]] ; then
-		# Don't obsessively try to find libffi
-		sed -i -e "s/.*\-iwithsysroot\/usr\/include\/ffi.*/\tpass/" setup.py || die
-	fi
-	distutils-r1_src_prepare
-}
-
-src_configure() {
-	tc-export PKG_CONFIG
-}
-
-python_test() {
-	local EPYTEST_IGNORE=(
-		# these tests call pip
-		testing/cffi0/test_zintegration.py
-	)
-
-	"${EPYTHON}" -c "import _cffi_backend as backend" || die
-	local -x PYTEST_DISABLE_PLUGIN_AUTOLOAD=1
-	epytest src/c testing
-}

diff --git a/dev-python/cffi/files/cffi-1.15.1-hppa.patch b/dev-python/cffi/files/cffi-1.15.1-hppa.patch
deleted file mode 100644
index e185e7b93929..000000000000
--- a/dev-python/cffi/files/cffi-1.15.1-hppa.patch
+++ /dev/null
@@ -1,59 +0,0 @@
-https://foss.heptapod.net/pypy/cffi/-/commit/ab11bfa551697cd2b61fdaa571c7975c06e6912c
-
-From ab11bfa551697cd2b61fdaa571c7975c06e6912c Mon Sep 17 00:00:00 2001
-From: John David Anglin <dave.anglin@bell.net>
-Date: Sun, 18 Dec 2022 14:52:04 -0500
-Subject: [PATCH] Fix the test failures on hppa
-
-A couple of years ago the libffi port for hppa-linux was changed from using a
-trampoline executed on the stack to the function descriptor technique used by
-ia64. This doesn't require an executable stack and is simpler. However,
-function pointers need to have the PLABEL bit set in the pointer. As a result,
-a simple cast can't be used to convert closure pointers to function pointers.
-
-python-cffi uses its own closure allocation so the problem can't be fixed in
-libffi.
-
-I added a macro CFFI_FN to do the conversion. It shouldn't affect other
-architectures. There is a similar define in libffi.
-
-Fixes: https://bugs.debian.org/1024271
-
---HG--
-branch : hppa
---- a/c/_cffi_backend.c
-+++ b/c/_cffi_backend.c
-@@ -60,6 +60,13 @@
- # endif
- #endif
- 
-+/* Convert from closure pointer to function pointer. */
-+#if defined(__hppa__) && !defined(__LP64__)
-+#define CFFI_FN(f) ((void (*)(void))((unsigned int)(f) | 2))
-+#else
-+#define CFFI_FN(f) ((void (*)(void))f)
-+#endif
-+
- 
- /* Define the following macro ONLY if you trust libffi's version of
-  * ffi_closure_alloc() more than the code in malloc_closure.h.
-@@ -3191,7 +3198,7 @@ cdata_call(CDataObject *cd, PyObject *args, PyObject *kwds)
- 
-     Py_BEGIN_ALLOW_THREADS
-     restore_errno();
--    ffi_call(&cif_descr->cif, (void (*)(void))(cd->c_data),
-+    ffi_call(&cif_descr->cif, (void (*)(void)) CFFI_FN(cd->c_data),
-              resultdata, buffer_array);
-     save_errno();
-     Py_END_ALLOW_THREADS
-@@ -6394,7 +6401,7 @@ static PyObject *b_callback(PyObject *self, PyObject *args)
-         goto error;
-     Py_INCREF(ct);
-     cd->head.c_type = ct;
--    cd->head.c_data = (char *)closure_exec;
-+    cd->head.c_data = (char *)CFFI_FN(closure_exec);
-     cd->head.c_weakreflist = NULL;
-     closure->user_data = NULL;
-     cd->closure = closure;
--- 
-GitLab

diff --git a/dev-python/cffi/files/cffi-1.15.1-py312.patch b/dev-python/cffi/files/cffi-1.15.1-py312.patch
deleted file mode 100644
index a5477d686dd7..000000000000
--- a/dev-python/cffi/files/cffi-1.15.1-py312.patch
+++ /dev/null
@@ -1,247 +0,0 @@
-diff -r 79b97f01064f cffi/vengine_cpy.py
---- a/cffi/vengine_cpy.py	Thu Feb 23 05:42:01 2023 +0100
-+++ b/cffi/vengine_cpy.py	Sat May 27 11:03:01 2023 +0200
-@@ -1,10 +1,16 @@
- #
- # DEPRECATED: implementation for ffi.verify()
- #
--import sys, imp
-+import sys
- from . import model
- from .error import VerificationError
- 
-+if sys.version_info >= (3, 12):
-+    import importlib.machinery
-+    import importlib.util
-+else:
-+    import imp
-+
- 
- class VCPythonEngine(object):
-     _class_key = 'x'
-@@ -20,16 +26,22 @@
-         pass
- 
-     def find_module(self, module_name, path, so_suffixes):
--        try:
--            f, filename, descr = imp.find_module(module_name, path)
--        except ImportError:
--            return None
--        if f is not None:
--            f.close()
-+        if sys.version_info >= (3, 12):
-+            spec = importlib.machinery.PathFinder.find_spec(module_name, path)
-+            if spec is None:
-+                return None
-+            filename = spec.origin
-+        else:
-+            try:
-+                f, filename, descr = imp.find_module(module_name, path)
-+            except ImportError:
-+                return None
-+            if f is not None:
-+                f.close()
-         # Note that after a setuptools installation, there are both .py
-         # and .so files with the same basename.  The code here relies on
-         # imp.find_module() locating the .so in priority.
--        if descr[0] not in so_suffixes:
-+        if not filename.endswith(tuple(so_suffixes)):
-             return None
-         return filename
- 
-@@ -145,15 +157,23 @@
-     def load_library(self, flags=None):
-         # XXX review all usages of 'self' here!
-         # import it as a new extension module
--        imp.acquire_lock()
-+        if sys.version_info < (3, 12):
-+            imp.acquire_lock()
-         try:
-             if hasattr(sys, "getdlopenflags"):
-                 previous_flags = sys.getdlopenflags()
-             try:
-                 if hasattr(sys, "setdlopenflags") and flags is not None:
-                     sys.setdlopenflags(flags)
--                module = imp.load_dynamic(self.verifier.get_module_name(),
--                                          self.verifier.modulefilename)
-+                if sys.version_info >= (3, 12):
-+                    spec = importlib.util.spec_from_file_location(
-+                        self.verifier.get_module_name(),
-+                        self.verifier.modulefilename)
-+                    module = importlib.util.module_from_spec(spec)
-+                    spec.loader.exec_module(module)
-+                else:
-+                    module = imp.load_dynamic(self.verifier.get_module_name(),
-+                                              self.verifier.modulefilename)
-             except ImportError as e:
-                 error = "importing %r: %s" % (self.verifier.modulefilename, e)
-                 raise VerificationError(error)
-@@ -161,7 +181,8 @@
-                 if hasattr(sys, "setdlopenflags"):
-                     sys.setdlopenflags(previous_flags)
-         finally:
--            imp.release_lock()
-+            if sys.version_info < (3, 12):
-+                imp.release_lock()
-         #
-         # call loading_cpy_struct() to get the struct layout inferred by
-         # the C compiler
-diff -r 79b97f01064f testing/cffi0/test_verify.py
---- a/testing/cffi0/test_verify.py	Thu Feb 23 05:42:01 2023 +0100
-+++ b/testing/cffi0/test_verify.py	Sat May 27 11:03:01 2023 +0200
-@@ -1575,10 +1575,16 @@
- def test_callback_in_thread():
-     if sys.platform == 'win32':
-         pytest.skip("pthread only")
--    import os, subprocess, imp
-+    import os, subprocess
-     arg = os.path.join(os.path.dirname(__file__), 'callback_in_thread.py')
--    g = subprocess.Popen([sys.executable, arg,
--                          os.path.dirname(imp.find_module('cffi')[1])])
-+    if sys.version_info >= (3, 12):
-+        import importlib.util
-+        spec = importlib.util.find_spec('cffi')
-+        cffi_path = os.path.dirname(spec.origin)
-+    else:
-+        import imp
-+        cffi_path = imp.find_module('cffi')[1]
-+    g = subprocess.Popen([sys.executable, arg, os.path.dirname(cffi_path)])
-     result = g.wait()
-     assert result == 0
- 
-diff -r 79b97f01064f testing/cffi0/test_zdistutils.py
---- a/testing/cffi0/test_zdistutils.py	Thu Feb 23 05:42:01 2023 +0100
-+++ b/testing/cffi0/test_zdistutils.py	Sat May 27 11:03:01 2023 +0200
-@@ -1,8 +1,9 @@
--import sys, os, imp, math, shutil
-+import sys, os, math, shutil
- import pytest
- from cffi import FFI, FFIError
- from cffi.verifier import Verifier, _locate_engine_class, _get_so_suffixes
- from cffi.ffiplatform import maybe_relative_path
-+from testing.support import load_dynamic
- from testing.udir import udir
- 
- 
-@@ -80,7 +81,7 @@
-         v.compile_module()
-         assert v.get_module_name().startswith('_cffi_')
-         if v.generates_python_module():
--            mod = imp.load_dynamic(v.get_module_name(), v.modulefilename)
-+            mod = load_dynamic(v.get_module_name(), v.modulefilename)
-             assert hasattr(mod, '_cffi_setup')
- 
-     def test_compile_module_explicit_filename(self):
-@@ -95,7 +96,7 @@
-         assert filename == v.modulefilename
-         assert v.get_module_name() == basename
-         if v.generates_python_module():
--            mod = imp.load_dynamic(v.get_module_name(), v.modulefilename)
-+            mod = load_dynamic(v.get_module_name(), v.modulefilename)
-             assert hasattr(mod, '_cffi_setup')
- 
-     def test_name_from_checksum_of_cdef(self):
-diff -r 79b97f01064f testing/cffi1/test_new_ffi_1.py
---- a/testing/cffi1/test_new_ffi_1.py	Thu Feb 23 05:42:01 2023 +0100
-+++ b/testing/cffi1/test_new_ffi_1.py	Sat May 27 11:03:01 2023 +0200
-@@ -1,5 +1,5 @@
- import pytest
--import platform, imp
-+import platform
- import sys, os, ctypes
- import cffi
- from testing.udir import udir
-@@ -91,7 +91,7 @@
- 
-     outputfilename = recompile(ffi1, "test_new_ffi_1", CCODE,
-                                tmpdir=str(udir))
--    module = imp.load_dynamic("test_new_ffi_1", outputfilename)
-+    module = load_dynamic("test_new_ffi_1", outputfilename)
-     ffi = module.ffi
-     construction_params = (ffi1, CCODE)
- 
-@@ -1619,8 +1619,8 @@
-         ffi2 = cffi.FFI(); ffi2.cdef(CDEF2)
-         outputfilename = recompile(ffi2, "test_multiple_independent_structs",
-                                    CDEF2, tmpdir=str(udir))
--        module = imp.load_dynamic("test_multiple_independent_structs",
--                                  outputfilename)
-+        module = load_dynamic("test_multiple_independent_structs",
-+                              outputfilename)
-         ffi1 = module.ffi
-         foo1 = ffi1.new("struct ab *", [10])
-         foo2 = ffi .new("struct ab *", [20, 30])
-@@ -1635,8 +1635,8 @@
-         outputfilename = recompile(ffi2,
-                                    "test_include_struct_union_enum_typedef",
-                                    CCODE, tmpdir=str(udir))
--        module = imp.load_dynamic("test_include_struct_union_enum_typedef",
--                                  outputfilename)
-+        module = load_dynamic("test_include_struct_union_enum_typedef",
-+                              outputfilename)
-         ffi2 = module.ffi
-         #
-         p = ffi2.new("struct nonpacked *", [b'A', -43141])
-@@ -1783,7 +1783,7 @@
-                                    "int myfunc(int x) { return x + 1; }\n"
-                                    "int myvar = -5;\n"
-                                    "#define MYFOO 42", tmpdir=str(udir))
--        imp.load_dynamic("_test_import_from_lib", outputfilename)
-+        load_dynamic("_test_import_from_lib", outputfilename)
-         from _test_import_from_lib.lib import myfunc, myvar, MYFOO
-         assert MYFOO == 42
-         assert myfunc(43) == 44
-diff -r 79b97f01064f testing/support.py
---- a/testing/support.py	Thu Feb 23 05:42:01 2023 +0100
-+++ b/testing/support.py	Sat May 27 11:03:01 2023 +0200
-@@ -1,5 +1,11 @@
- import sys, os
- 
-+if sys.version_info >= (3, 12):
-+    import importlib.util
-+else:
-+    import imp
-+
-+
- if sys.version_info < (3,):
-     __all__ = ['u', 'arraytostring']
- 
-@@ -16,7 +22,7 @@
-         return a.tostring()
- 
- else:
--    __all__ = ['u', 'unicode', 'long', 'arraytostring']
-+    __all__ = ['u', 'unicode', 'long', 'arraytostring', 'load_dynamic']
-     u = ""
-     unicode = str
-     long = int
-@@ -71,15 +77,27 @@
-     def getvalue(self):
-         return self._value
- 
-+
-+def load_dynamic(module_name, outputfilename):
-+    if sys.version_info >= (3, 12):
-+        import importlib.util
-+        spec = importlib.util.spec_from_file_location(module_name,
-+                                                      outputfilename)
-+        module = importlib.util.module_from_spec(spec)
-+        spec.loader.exec_module(module)
-+        return module
-+    else:
-+        return imp.load_dynamic(module_name, outputfilename)
-+
-+
- def _verify(ffi, module_name, preamble, *args, **kwds):
--    import imp
-     from cffi.recompiler import recompile
-     from .udir import udir
-     assert module_name not in sys.modules, "module name conflict: %r" % (
-         module_name,)
-     kwds.setdefault('tmpdir', str(udir))
-     outputfilename = recompile(ffi, module_name, preamble, *args, **kwds)
--    module = imp.load_dynamic(module_name, outputfilename)
-+    module = load_dynamic(module_name, outputfilename)
-     #
-     # hack hack hack: copy all *bound methods* from module.ffi back to the
-     # ffi instance.  Then calls like ffi.new() will invoke module.ffi.new().

diff --git a/dev-python/cffi/files/cffi-1.15.1-python3.11-tests.patch b/dev-python/cffi/files/cffi-1.15.1-python3.11-tests.patch
deleted file mode 100644
index e3be1c247877..000000000000
--- a/dev-python/cffi/files/cffi-1.15.1-python3.11-tests.patch
+++ /dev/null
@@ -1,90 +0,0 @@
-https://foss.heptapod.net/pypy/cffi/-/commit/8a3c2c816d789639b49d3ae867213393ed7abdff
-
-From 8a3c2c816d789639b49d3ae867213393ed7abdff Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
-Date: Fri, 15 Jul 2022 16:11:37 +0200
-Subject: [PATCH] Adjust tests for a last minute Python 3.11 change in the
- traceback format
-
-See https://github.com/python/cpython/issues/93883
-and https://github.com/python/cpython/pull/93994
-
---HG--
-branch : python3.11.0b4
---- a/c/test_c.py
-+++ b/c/test_c.py
-@@ -1342,11 +1342,11 @@ def test_callback_exception():
-     except ImportError:
-         import io as cStringIO    # Python 3
-     import linecache
--    def matches(istr, ipattern, ipattern38, ipattern311):
-+    def matches(istr, ipattern, ipattern38, ipattern311=None):
-         if sys.version_info >= (3, 8):
-             ipattern = ipattern38
-         if sys.version_info >= (3, 11):
--            ipattern = ipattern311
-+            ipattern = ipattern311 or ipattern38
-         str, pattern = istr, ipattern
-         while '$' in pattern:
-             i = pattern.index('$')
-@@ -1400,16 +1400,6 @@ Traceback (most recent call last):
-   File "$", line $, in check_value
-     $
- ValueError: 42
--""", """\
--Exception ignored from cffi callback <function$Zcb1 at 0x$>:
--Traceback (most recent call last):
--  File "$", line $, in Zcb1
--    $
--    $
--  File "$", line $, in check_value
--    $
--    $
--ValueError: 42
- """)
-         sys.stderr = cStringIO.StringIO()
-         bigvalue = 20000
-@@ -1424,13 +1414,6 @@ Traceback (most recent call last):
-   File "$", line $, in test_callback_exception
-     $
- OverflowError: integer 60000 does not fit 'short'
--""", """\
--Exception ignored from cffi callback <function$Zcb1 at 0x$>, trying to convert the result back to C:
--Traceback (most recent call last):
--  File "$", line $, in test_callback_exception
--    $
--    $
--OverflowError: integer 60000 does not fit 'short'
- """)
-         sys.stderr = cStringIO.StringIO()
-         bigvalue = 20000
-@@ -1479,19 +1462,6 @@ Traceback (most recent call last):
-   File "$", line $, in test_callback_exception
-     $
- TypeError: $integer$
--""", """\
--Exception ignored from cffi callback <function$Zcb1 at 0x$>, trying to convert the result back to C:
--Traceback (most recent call last):
--  File "$", line $, in test_callback_exception
--    $
--    $
--OverflowError: integer 60000 does not fit 'short'
--Exception ignored during handling of the above exception by 'onerror':
--Traceback (most recent call last):
--  File "$", line $, in test_callback_exception
--    $
--    $
--TypeError: $integer$
- """)
-         #
-         sys.stderr = cStringIO.StringIO()
-@@ -1526,7 +1496,6 @@ Exception ignored from cffi callback <function$Zcb1 at 0x$>, trying to convert t
- Traceback (most recent call last):
-   File "$", line $, in test_callback_exception
-     $
--    $
- OverflowError: integer 60000 does not fit 'short'
- Exception ignored during handling of the above exception by 'onerror':
- Traceback (most recent call last):
--- 
-GitLab


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-10-28 18:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-05  1:18 [gentoo-commits] repo/gentoo:master commit in: dev-python/cffi/, dev-python/cffi/files/ Sam James
  -- strict thread matches above, loose matches on Subject: below --
2023-10-28 18:24 Michał Górny
2023-05-27 13:21 Michał Górny
2023-04-03  6:40 Sam James

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox