diff --git a/build/pkgs/cypari/patches/cython3-legacy.patch b/build/pkgs/cypari/patches/cython3-legacy.patch new file mode 100644 index 00000000000..41392fe80d7 --- /dev/null +++ b/build/pkgs/cypari/patches/cython3-legacy.patch @@ -0,0 +1,32 @@ +commit 8ef356a4eb936c37f55a5c501f3a955e6740c0c5 +Author: Gonzalo Tornaría +Date: Wed Jul 19 19:45:23 2023 -0300 + + cython3 support using legacy directives + +diff --git a/cypari2/gen.pyx b/cypari2/gen.pyx +index 247b1ad..75050a0 100644 +--- a/cypari2/gen.pyx ++++ b/cypari2/gen.pyx +@@ -329,7 +329,7 @@ cdef class Gen(Gen_base): + >>> pari = Pari() + >>> L = pari("vector(10,i,i^2)") + >>> L.__iter__() +- ++ <...generator object at ...> + >>> [x for x in L] + [1, 4, 9, 16, 25, 36, 49, 64, 81, 100] + >>> list(L) +diff --git a/setup.py b/setup.py +index 2188711..455337f 100755 +--- a/setup.py ++++ b/setup.py +@@ -36,6 +36,8 @@ class build_ext(_build_ext): + "binding": True, + "cdivision": True, + "language_level": 2, ++ "legacy_implicit_noexcept": True, ++ "c_api_binop_methods": True, + } + + _build_ext.finalize_options(self) diff --git a/build/pkgs/cysignals/patches/cython3-fix-warning.patch b/build/pkgs/cysignals/patches/cython3-fix-warning.patch new file mode 100644 index 00000000000..98cad9625e4 --- /dev/null +++ b/build/pkgs/cysignals/patches/cython3-fix-warning.patch @@ -0,0 +1,13 @@ +diff --git a/src/cysignals/signals.pxd.in b/src/cysignals/signals.pxd.in +index c86e085..a98c8d1 100644 +--- a/src/cysignals/signals.pxd.in ++++ b/src/cysignals/signals.pxd.in +@@ -54,7 +54,7 @@ cdef extern from "macros.h" nogil: + # can be used to make Cython check whether there is a pending exception + # (PyErr_Occurred() is non-NULL). To Cython, it will look like + # cython_check_exception() actually raised the exception. +-cdef inline void cython_check_exception() nogil except *: ++cdef inline void cython_check_exception() except * nogil: + pass + + diff --git a/build/pkgs/cysignals/patches/cython3-legacy.patch b/build/pkgs/cysignals/patches/cython3-legacy.patch new file mode 100644 index 00000000000..274575d5d35 --- /dev/null +++ b/build/pkgs/cysignals/patches/cython3-legacy.patch @@ -0,0 +1,30 @@ +commit 9996a4028ddc7f9a5ffda3df65d5b7d3b7df8aa5 +Author: Gonzalo Tornaría +Date: Wed Jul 19 18:34:57 2023 -0300 + + cython3 support using legacy directives + +diff --git a/setup.py b/setup.py +index 37acdfc..f68270b 100755 +--- a/setup.py ++++ b/setup.py +@@ -157,13 +157,17 @@ class build_ext(_build_ext): + # Run Cython with -Werror on continuous integration services + # with Python 3.6 or later + from Cython.Compiler import Options +- Options.warning_errors = True ++ Options.warning_errors = False + + from Cython.Build.Dependencies import cythonize + return cythonize(extensions, + build_dir=cythonize_dir, + include_path=["src", os.path.join(cythonize_dir, "src")], +- compiler_directives=dict(binding=True, language_level=2)) ++ compiler_directives=dict( ++ binding=True, ++ language_level=2, ++ legacy_implicit_noexcept=True, ++ )) + + + class build_py(_build_py): diff --git a/build/pkgs/cython/checksums.ini b/build/pkgs/cython/checksums.ini index 175914867ed..5d0bc66c242 100644 --- a/build/pkgs/cython/checksums.ini +++ b/build/pkgs/cython/checksums.ini @@ -1,5 +1,5 @@ tarball=Cython-VERSION.tar.gz -sha1=762987c737acfe7532cb3da38b450fb6e0cf1d7b -md5=a4d0f9fbc9c137f1a88937cd40e8c5ee -cksum=2260471737 +sha1=08eb99f7c95b7ca667b1547575e7369d8064b4b3 +md5=00def3f2b96c393098e01eb2f1f169ad +cksum=2321746451 upstream_url=https://pypi.io/packages/source/C/Cython/Cython-VERSION.tar.gz diff --git a/build/pkgs/cython/dependencies b/build/pkgs/cython/dependencies index 47296a7bace..7cb4e63bf76 100644 --- a/build/pkgs/cython/dependencies +++ b/build/pkgs/cython/dependencies @@ -1,4 +1,4 @@ - | $(PYTHON_TOOLCHAIN) $(PYTHON) + | $(PYTHON_TOOLCHAIN) $(PYTHON) pythran ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/cython/install-requires.txt b/build/pkgs/cython/install-requires.txt index b8a968fa247..3693d637891 100644 --- a/build/pkgs/cython/install-requires.txt +++ b/build/pkgs/cython/install-requires.txt @@ -1 +1 @@ -cython >=0.29.21, <1.0 +cython >=3.0, <4.0 diff --git a/build/pkgs/cython/package-version.txt b/build/pkgs/cython/package-version.txt index 5232b0aaea8..b5021469305 100644 --- a/build/pkgs/cython/package-version.txt +++ b/build/pkgs/cython/package-version.txt @@ -1 +1 @@ -0.29.36 +3.0.2 diff --git a/build/pkgs/cython/patches/0001-cython.trashcan-directive-to-enable-the-Python-trash.patch b/build/pkgs/cython/patches/0001-cython.trashcan-directive-to-enable-the-Python-trash.patch deleted file mode 100644 index 0cd3f35df32..00000000000 --- a/build/pkgs/cython/patches/0001-cython.trashcan-directive-to-enable-the-Python-trash.patch +++ /dev/null @@ -1,355 +0,0 @@ -See https://github.com/cython/cython/pull/2842 - -and https://github.com/cython/cython/pull/4475 - -commit c47c4ef735c4b7f1863b21bbe6f112b06c4aad05 -Author: Jeroen Demeyer -Date: Thu Feb 14 10:02:41 2019 +0100 - - @cython.trashcan directive to enable the Python trashcan for deallocations - -diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py -index 56845330d..3a3e8a956 100644 ---- a/Cython/Compiler/ModuleNode.py -+++ b/Cython/Compiler/ModuleNode.py -@@ -1443,6 +1443,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): - - is_final_type = scope.parent_type.is_final_type - needs_gc = scope.needs_gc() -+ needs_trashcan = scope.needs_trashcan() - - weakref_slot = scope.lookup_here("__weakref__") if not scope.is_closure_class_scope else None - if weakref_slot not in scope.var_entries: -@@ -1481,6 +1482,11 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): - # running this destructor. - code.putln("PyObject_GC_UnTrack(o);") - -+ if needs_trashcan: -+ code.globalstate.use_utility_code( -+ UtilityCode.load_cached("PyTrashcan", "ExtensionTypes.c")) -+ code.putln("__Pyx_TRASHCAN_BEGIN(o, %s)" % slot_func_cname) -+ - # call the user's __dealloc__ - self.generate_usr_dealloc_call(scope, code) - -@@ -1554,6 +1560,10 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): - code.putln("(*Py_TYPE(o)->tp_free)(o);") - if freelist_size: - code.putln("}") -+ -+ if needs_trashcan: -+ code.putln("__Pyx_TRASHCAN_END") -+ - code.putln( - "}") - -diff --git a/Cython/Compiler/Options.py b/Cython/Compiler/Options.py -index d03119fca..539629926 100644 ---- a/Cython/Compiler/Options.py -+++ b/Cython/Compiler/Options.py -@@ -319,7 +319,8 @@ directive_types = { - 'freelist': int, - 'c_string_type': one_of('bytes', 'bytearray', 'str', 'unicode'), - 'c_string_encoding': normalise_encoding_name, -- 'cpow': bool -+ 'cpow': bool, -+ 'trashcan': bool, - } - - for key, val in _directive_defaults.items(): -@@ -362,6 +363,7 @@ directive_scopes = { # defaults to available everywhere - 'np_pythran': ('module',), - 'fast_gil': ('module',), - 'iterable_coroutine': ('module', 'function'), -+ 'trashcan' : ('cclass',), - } - - -diff --git a/Cython/Compiler/PyrexTypes.py b/Cython/Compiler/PyrexTypes.py -index c309bd04b..9231130b5 100644 ---- a/Cython/Compiler/PyrexTypes.py -+++ b/Cython/Compiler/PyrexTypes.py -@@ -1129,6 +1129,7 @@ class PyObjectType(PyrexType): - is_extern = False - is_subclassed = False - is_gc_simple = False -+ builtin_trashcan = False # builtin type using trashcan - - def __str__(self): - return "Python object" -@@ -1183,10 +1184,14 @@ class PyObjectType(PyrexType): - - - builtin_types_that_cannot_create_refcycles = set([ -- 'bool', 'int', 'long', 'float', 'complex', -+ 'object', 'bool', 'int', 'long', 'float', 'complex', - 'bytearray', 'bytes', 'unicode', 'str', 'basestring' - ]) - -+builtin_types_with_trashcan = set([ -+ 'dict', 'list', 'set', 'frozenset', 'tuple', 'type', -+]) -+ - - class BuiltinObjectType(PyObjectType): - # objstruct_cname string Name of PyObject struct -@@ -1211,6 +1216,7 @@ class BuiltinObjectType(PyObjectType): - self.typeptr_cname = "(&%s)" % cname - self.objstruct_cname = objstruct_cname - self.is_gc_simple = name in builtin_types_that_cannot_create_refcycles -+ self.builtin_trashcan = name in builtin_types_with_trashcan - if name == 'type': - # Special case the type type, as many C API calls (and other - # libraries) actually expect a PyTypeObject* for type arguments. -diff --git a/Cython/Compiler/Symtab.py b/Cython/Compiler/Symtab.py -index 7361a55ae..f0c311ba6 100644 ---- a/Cython/Compiler/Symtab.py -+++ b/Cython/Compiler/Symtab.py -@@ -2043,7 +2043,7 @@ class PyClassScope(ClassScope): - class CClassScope(ClassScope): - # Namespace of an extension type. - # -- # parent_type CClassType -+ # parent_type PyExtensionType - # #typeobj_cname string or None - # #objstruct_cname string - # method_table_cname string -@@ -2087,6 +2087,22 @@ class CClassScope(ClassScope): - return not self.parent_type.is_gc_simple - return False - -+ def needs_trashcan(self): -+ # If the trashcan directive is explicitly set to False, -+ # unconditionally disable the trashcan. -+ directive = self.directives.get('trashcan') -+ if directive is False: -+ return False -+ # If the directive is set to True and the class has Python-valued -+ # C attributes, then it should use the trashcan in tp_dealloc. -+ if directive and self.has_cyclic_pyobject_attrs: -+ return True -+ # Use the trashcan if the base class uses it -+ base_type = self.parent_type.base_type -+ if base_type and base_type.scope is not None: -+ return base_type.scope.needs_trashcan() -+ return self.parent_type.builtin_trashcan -+ - def needs_tp_clear(self): - """ - Do we need to generate an implementation for the tp_clear slot? Can -diff --git a/Cython/Utility/ExtensionTypes.c b/Cython/Utility/ExtensionTypes.c -index dc187ab49..f359165df 100644 ---- a/Cython/Utility/ExtensionTypes.c -+++ b/Cython/Utility/ExtensionTypes.c -@@ -119,6 +119,54 @@ static int __Pyx_PyType_Ready(PyTypeObject *t) { - return r; - } - -+/////////////// PyTrashcan.proto /////////////// -+ -+// These macros are taken from https://github.com/python/cpython/pull/11841 -+// Unlike the Py_TRASHCAN_SAFE_BEGIN/Py_TRASHCAN_SAFE_END macros, they -+// allow dealing correctly with subclasses. -+ -+// This requires CPython version >= 2.7.4 -+// (or >= 3.2.4 but we don't support such old Python 3 versions anyway) -+#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03080000 -+// https://github.com/python/cpython/pull/11841 merged so Cython reimplementation -+// is no longer necessary -+#define __Pyx_TRASHCAN_BEGIN Py_TRASHCAN_BEGIN -+#define __Pyx_TRASHCAN_END Py_TRASHCAN_END -+#elif CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x02070400 -+#define __Pyx_TRASHCAN_BEGIN_CONDITION(op, cond) \ -+ do { \ -+ PyThreadState *_tstate = NULL; \ -+ // If "cond" is false, then _tstate remains NULL and the deallocator -+ // is run normally without involving the trashcan -+ if (cond) { \ -+ _tstate = PyThreadState_GET(); \ -+ if (_tstate->trash_delete_nesting >= PyTrash_UNWIND_LEVEL) { \ -+ // Store the object (to be deallocated later) and jump past -+ // Py_TRASHCAN_END, skipping the body of the deallocator -+ _PyTrash_thread_deposit_object((PyObject*)(op)); \ -+ break; \ -+ } \ -+ ++_tstate->trash_delete_nesting; \ -+ } -+ // The body of the deallocator is here. -+#define __Pyx_TRASHCAN_END \ -+ if (_tstate) { \ -+ --_tstate->trash_delete_nesting; \ -+ if (_tstate->trash_delete_later && _tstate->trash_delete_nesting <= 0) \ -+ _PyTrash_thread_destroy_chain(); \ -+ } \ -+ } while (0); -+ -+#define __Pyx_TRASHCAN_BEGIN(op, dealloc) __Pyx_TRASHCAN_BEGIN_CONDITION(op, \ -+ Py_TYPE(op)->tp_dealloc == (destructor)(dealloc)) -+ -+#else -+// The trashcan is a no-op on other Python implementations -+// or old CPython versions -+#define __Pyx_TRASHCAN_BEGIN(op, dealloc) -+#define __Pyx_TRASHCAN_END -+#endif -+ - /////////////// CallNextTpDealloc.proto /////////////// - - static void __Pyx_call_next_tp_dealloc(PyObject* obj, destructor current_tp_dealloc); -diff --git a/tests/run/trashcan.pyx b/tests/run/trashcan.pyx -new file mode 100644 -index 000000000..93a501ff8 ---- /dev/null -+++ b/tests/run/trashcan.pyx -@@ -0,0 +1,148 @@ -+# mode: run -+ -+cimport cython -+ -+ -+# Count number of times an object was deallocated twice. This should remain 0. -+cdef int double_deallocations = 0 -+def assert_no_double_deallocations(): -+ global double_deallocations -+ err = double_deallocations -+ double_deallocations = 0 -+ assert not err -+ -+ -+# Compute x = f(f(f(...(None)...))) nested n times and throw away the result. -+# The real test happens when exiting this function: then a big recursive -+# deallocation of x happens. We are testing two things in the tests below: -+# that Python does not crash and that no double deallocation happens. -+# See also https://github.com/python/cpython/pull/11841 -+def recursion_test(f, int n=2**20): -+ x = None -+ cdef int i -+ for i in range(n): -+ x = f(x) -+ -+ -+@cython.trashcan(True) -+cdef class Recurse: -+ """ -+ >>> recursion_test(Recurse) -+ >>> assert_no_double_deallocations() -+ """ -+ cdef public attr -+ cdef int deallocated -+ -+ def __init__(self, x): -+ self.attr = x -+ -+ def __dealloc__(self): -+ # Check that we're not being deallocated twice -+ global double_deallocations -+ double_deallocations += self.deallocated -+ self.deallocated = 1 -+ -+ -+cdef class RecurseSub(Recurse): -+ """ -+ >>> recursion_test(RecurseSub) -+ >>> assert_no_double_deallocations() -+ """ -+ cdef int subdeallocated -+ -+ def __dealloc__(self): -+ # Check that we're not being deallocated twice -+ global double_deallocations -+ double_deallocations += self.subdeallocated -+ self.subdeallocated = 1 -+ -+ -+@cython.freelist(4) -+@cython.trashcan(True) -+cdef class RecurseFreelist: -+ """ -+ >>> recursion_test(RecurseFreelist) -+ >>> recursion_test(RecurseFreelist, 1000) -+ >>> assert_no_double_deallocations() -+ """ -+ cdef public attr -+ cdef int deallocated -+ -+ def __init__(self, x): -+ self.attr = x -+ -+ def __dealloc__(self): -+ # Check that we're not being deallocated twice -+ global double_deallocations -+ double_deallocations += self.deallocated -+ self.deallocated = 1 -+ -+ -+# Subclass of list => uses trashcan by default -+# As long as https://github.com/python/cpython/pull/11841 is not fixed, -+# this does lead to double deallocations, so we skip that check. -+cdef class RecurseList(list): -+ """ -+ >>> RecurseList(42) -+ [42] -+ >>> recursion_test(RecurseList) -+ """ -+ def __init__(self, x): -+ super().__init__((x,)) -+ -+ -+# Some tests where the trashcan is NOT used. When the trashcan is not used -+# in a big recursive deallocation, the __dealloc__s of the base classs are -+# only run after the __dealloc__s of the subclasses. -+# We use this to detect trashcan usage. -+cdef int base_deallocated = 0 -+cdef int trashcan_used = 0 -+def assert_no_trashcan_used(): -+ global base_deallocated, trashcan_used -+ err = trashcan_used -+ trashcan_used = base_deallocated = 0 -+ assert not err -+ -+ -+cdef class Base: -+ def __dealloc__(self): -+ global base_deallocated -+ base_deallocated = 1 -+ -+ -+# Trashcan disabled by default -+cdef class Sub1(Base): -+ """ -+ >>> recursion_test(Sub1, 100) -+ >>> assert_no_trashcan_used() -+ """ -+ cdef public attr -+ -+ def __init__(self, x): -+ self.attr = x -+ -+ def __dealloc__(self): -+ global base_deallocated, trashcan_used -+ trashcan_used += base_deallocated -+ -+ -+@cython.trashcan(True) -+cdef class Middle(Base): -+ cdef public foo -+ -+ -+# Trashcan disabled explicitly -+@cython.trashcan(False) -+cdef class Sub2(Middle): -+ """ -+ >>> recursion_test(Sub2, 1000) -+ >>> assert_no_trashcan_used() -+ """ -+ cdef public attr -+ -+ def __init__(self, x): -+ self.attr = x -+ -+ def __dealloc__(self): -+ global base_deallocated, trashcan_used -+ trashcan_used += base_deallocated --- -2.37.1 (Apple Git-137.1) - diff --git a/build/pkgs/cython/patches/0001-rebased-PR2946.patch b/build/pkgs/cython/patches/0001-rebased-PR2946.patch deleted file mode 100644 index 36764e7291e..00000000000 --- a/build/pkgs/cython/patches/0001-rebased-PR2946.patch +++ /dev/null @@ -1,193 +0,0 @@ -From 0b69e95aa702fb9f52b285360d5c5ae5e7fbb745 Mon Sep 17 00:00:00 2001 -From: Dima Pasechnik -Date: Thu, 16 Mar 2023 22:35:09 +0000 -Subject: [PATCH] rebased PR2946 - ---- - Cython/Compiler/Main.py | 44 +++++++++++++++---- - Cython/Utils.py | 22 +++++++--- - runtests.py | 1 + - .../build/cythonize_pep420_namespace.srctree | 44 +++++++++++++++++++ - 4 files changed, 96 insertions(+), 15 deletions(-) - create mode 100644 tests/build/cythonize_pep420_namespace.srctree - -diff --git a/Cython/Compiler/Main.py b/Cython/Compiler/Main.py -index 9c57452ba..1143ecf03 100644 ---- a/Cython/Compiler/Main.py -+++ b/Cython/Compiler/Main.py -@@ -809,32 +809,58 @@ def search_include_directories(dirs, qualified_name, suffix, pos, include=False) - else: - dirs = (Utils.find_root_package_dir(file_desc.filename),) + dirs - -+ # search for dotted filename e.g. /foo.bar.pxd - dotted_filename = qualified_name - if suffix: - dotted_filename += suffix - -+ for dirname in dirs: -+ path = os.path.join(dirname, dotted_filename) -+ if os.path.exists(path): -+ return path -+ -+ # search for filename in package structure e.g. /foo/bar.pxd or /foo/bar/__init__.pxd - if not include: -+ - names = qualified_name.split('.') - package_names = tuple(names[:-1]) - module_name = names[-1] - module_filename = module_name + suffix - package_filename = "__init__" + suffix - -- for dirname in dirs: -- path = os.path.join(dirname, dotted_filename) -- if os.path.exists(path): -- return path -- -- if not include: -- package_dir = Utils.check_package_dir(dirname, package_names) -+ # search for standard packages first - PEP420 -+ namespace_dirs = [] -+ for dirname in dirs: -+ package_dir, is_namespace = Utils.check_package_dir(dirname, package_names) - if package_dir is not None: -+ -+ if is_namespace: -+ namespace_dirs.append(package_dir) -+ continue -+ -+ # matches modules of the form: /foo/bar.pxd - path = os.path.join(package_dir, module_filename) - if os.path.exists(path): - return path -- path = os.path.join(package_dir, module_name, -- package_filename) -+ -+ # matches modules of the form: /foo/bar/__init__.pxd -+ path = os.path.join(package_dir, module_name, package_filename) - if os.path.exists(path): - return path -+ -+ # search for namespaces second - PEP420 -+ for package_dir in namespace_dirs: -+ -+ # matches modules of the form: /foo/bar.pxd -+ path = os.path.join(package_dir, module_filename) -+ if os.path.exists(path): -+ return path -+ -+ # matches modules of the form: /foo/bar/__init__.pxd -+ path = os.path.join(package_dir, module_name, package_filename) -+ if os.path.exists(path): -+ return path -+ - return None - - -diff --git a/Cython/Utils.py b/Cython/Utils.py -index 69563794c..77a48fbd7 100644 ---- a/Cython/Utils.py -+++ b/Cython/Utils.py -@@ -135,15 +135,19 @@ def find_root_package_dir(file_path): - return dir - - @cached_function --def check_package_dir(dir, package_names): -+def check_package_dir(dir_path, package_names): -+ namespace = True - for dirname in package_names: -- dir = os.path.join(dir, dirname) -- if not is_package_dir(dir): -- return None -- return dir -+ dir_path = os.path.join(dir_path, dirname) -+ has_init = contains_init(dir_path) -+ if not namespace and not has_init: -+ return None, False -+ elif has_init: -+ namespace = False -+ return dir_path, namespace - - @cached_function --def is_package_dir(dir_path): -+def contains_init(dir_path): - for filename in ("__init__.py", - "__init__.pyc", - "__init__.pyx", -@@ -152,6 +156,12 @@ def is_package_dir(dir_path): - if path_exists(path): - return 1 - -+ -+def is_package_dir(dir_path): -+ if contains_init(dir_path): -+ return 1 -+ -+ - @cached_function - def path_exists(path): - # try on the filesystem first -diff --git a/runtests.py b/runtests.py -index 91a0dd257..7d0446384 100755 ---- a/runtests.py -+++ b/runtests.py -@@ -415,6 +415,7 @@ VER_DEP_MODULES = { - 'run.special_methods_T561_py2' - ]), - (3,3) : (operator.lt, lambda x: x in ['build.package_compilation', -+ 'build.cythonize_pep420_namespace', - 'run.yield_from_py33', - 'pyximport.pyximport_namespace', - ]), -diff --git a/tests/build/cythonize_pep420_namespace.srctree b/tests/build/cythonize_pep420_namespace.srctree -new file mode 100644 -index 000000000..6a031e417 ---- /dev/null -+++ b/tests/build/cythonize_pep420_namespace.srctree -@@ -0,0 +1,44 @@ -+PYTHON setup.py build_ext --inplace -+PYTHON -c "import runner" -+ -+######## setup.py ######## -+ -+from Cython.Build.Dependencies import cythonize -+ -+from distutils.core import setup, Extension -+ -+setup( -+ ext_modules=cythonize([ -+ Extension("nsp.m1.a", ["nsp/m1/a.pyx"]), -+ Extension("nsp.m2.b", ["nsp/m2/b.pyx"]) -+ ]), -+) -+ -+######## nsp/m1/__init__.py ######## -+ -+######## nsp/m1/a.pyx ######## -+ -+cdef class A: -+ pass -+ -+######## nsp/m1/a.pxd ######## -+ -+cdef class A: -+ pass -+ -+######## nsp/m2/__init__.py ######## -+ -+######## nsp/m2/b.pyx ######## -+ -+from nsp.m1.a cimport A -+ -+cdef class B(A): -+ pass -+ -+######## runner.py ######## -+ -+from nsp.m1.a import A -+from nsp.m2.b import B -+ -+a = A() -+b = B() --- -2.37.1 (Apple Git-137.1) - diff --git a/build/pkgs/fpylll/patches/cython3-legacy.patch b/build/pkgs/fpylll/patches/cython3-legacy.patch new file mode 100644 index 00000000000..808c14e9c1b --- /dev/null +++ b/build/pkgs/fpylll/patches/cython3-legacy.patch @@ -0,0 +1,37 @@ +commit b6e12c2b0648e84b26dcf0aac507a5b4d9dde301 +Author: Gonzalo Tornaría +Date: Wed Jul 19 20:38:01 2023 -0300 + + cython3 support using legacy directives + +diff --git a/setup.py b/setup.py +index 274836f..8fc5af5 100755 +--- a/setup.py ++++ b/setup.py +@@ -123,7 +123,12 @@ class build_ext(_build_ext, object): + self.extensions, + include_path=["src"], + build_dir=self.cythonize_dir, +- compiler_directives={"binding": True, "embedsignature": True, "language_level": 2}, ++ compiler_directives={ ++ "binding": True, ++ "embedsignature": True, ++ "language_level": 2, ++ "legacy_implicit_noexcept": True, ++ }, + ) + super(build_ext, self).run() + +diff --git a/src/fpylll/fplll/enumeration_callback_helper.h b/src/fpylll/fplll/enumeration_callback_helper.h +index c099430..706162f 100644 +--- a/src/fpylll/fplll/enumeration_callback_helper.h ++++ b/src/fpylll/fplll/enumeration_callback_helper.h +@@ -5,7 +5,7 @@ + #include + #include + +-extern "C" { ++extern "C++" { + bool evaluator_callback_call_obj(PyObject *obj, int n, double *new_sol_coord); + } + diff --git a/build/pkgs/numpy/patches/cython3-legacy.patch b/build/pkgs/numpy/patches/cython3-legacy.patch new file mode 100644 index 00000000000..dfcb9c4a69c --- /dev/null +++ b/build/pkgs/numpy/patches/cython3-legacy.patch @@ -0,0 +1,12 @@ +diff --git a/tools/cythonize.py b/tools/cythonize.py +index 002b2fa..c04422e 100755 +--- a/tools/cythonize.py ++++ b/tools/cythonize.py +@@ -47,6 +47,7 @@ def process_pyx(fromfile, tofile): + flags = ['-3', '--fast-fail'] + if tofile.endswith('.cxx'): + flags.append('--cplus') ++ flags += ['--directive', 'legacy_implicit_noexcept=true'] + + subprocess.check_call( + [sys.executable, '-m', 'cython'] + flags + ["-o", tofile, fromfile]) diff --git a/build/pkgs/pplpy/patches/cython3-legacy.patch b/build/pkgs/pplpy/patches/cython3-legacy.patch new file mode 100644 index 00000000000..a038da16d6b --- /dev/null +++ b/build/pkgs/pplpy/patches/cython3-legacy.patch @@ -0,0 +1,22 @@ +commit e6f3e66154138ce3e31e803e74b8c71787c70acc +Author: Gonzalo Tornaría +Date: Wed Jul 19 20:47:52 2023 -0300 + + cython3 support using legacy directives + +diff --git a/setup.py b/setup.py +index 13d543b..55dcd34 100755 +--- a/setup.py ++++ b/setup.py +@@ -38,7 +38,11 @@ class build_ext(_build_ext): + self.extensions[:] = cythonize( + self.extensions, + include_path=sys.path, +- compiler_directives={'embedsignature': True}) ++ compiler_directives={ ++ 'embedsignature': True, ++ 'legacy_implicit_noexcept': True, ++ 'c_api_binop_methods': True, ++ }) + + _build_ext.run(self) diff --git a/build/pkgs/pplpy/patches/relative-import.patch b/build/pkgs/pplpy/patches/relative-import.patch new file mode 100644 index 00000000000..3c011203367 --- /dev/null +++ b/build/pkgs/pplpy/patches/relative-import.patch @@ -0,0 +1,21 @@ +From aaa28537fa7ea061ebb8d5131b1e23673eaf741d Mon Sep 17 00:00:00 2001 +From: Matthias Koeppe +Date: Sun, 31 Jul 2022 12:39:34 -0700 +Subject: [PATCH] ppl/bit_arrays.pxd: Use relative cimport + +--- + ppl/bit_arrays.pxd | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/ppl/bit_arrays.pxd b/ppl/bit_arrays.pxd +index eb57434..145a978 100644 +--- a/ppl/bit_arrays.pxd ++++ b/ppl/bit_arrays.pxd +@@ -1,4 +1,4 @@ +-from ppl_decl cimport * ++from .ppl_decl cimport * + + cdef class Bit_Row(object): + cdef PPL_Bit_Row *thisptr +-- +GitLab diff --git a/build/pkgs/pythran/checksums.ini b/build/pkgs/pythran/checksums.ini index dc9beccf6b6..2a926b36347 100644 --- a/build/pkgs/pythran/checksums.ini +++ b/build/pkgs/pythran/checksums.ini @@ -1,5 +1,5 @@ tarball=pythran-VERSION.tar.gz -sha1=dd675e9ccc93379b529687328ca558d5617eb1c6 -md5=3090288af50566af75cb058d1878aaad -cksum=3968085663 +sha1=8f997393d123a6185dbf2be0ead588df004c6c4c +md5=2885a2974b9b523439761bfd8bc54f03 +cksum=1307669216 upstream_url=https://pypi.io/packages/source/p/pythran/pythran-VERSION.tar.gz diff --git a/build/pkgs/pythran/dependencies b/build/pkgs/pythran/dependencies index 3845adb7a2c..89cdb86e634 100644 --- a/build/pkgs/pythran/dependencies +++ b/build/pkgs/pythran/dependencies @@ -1,4 +1,4 @@ - beniget gast ply numpy | $(PYTHON_TOOLCHAIN) $(PYTHON) +beniget gast ply | $(PYTHON_TOOLCHAIN) $(PYTHON) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/pythran/package-version.txt b/build/pkgs/pythran/package-version.txt index c317a91891f..a803cc227fe 100644 --- a/build/pkgs/pythran/package-version.txt +++ b/build/pkgs/pythran/package-version.txt @@ -1 +1 @@ -0.13.1 +0.14.0 diff --git a/src/doc/en/thematic_tutorials/coercion_and_categories.rst b/src/doc/en/thematic_tutorials/coercion_and_categories.rst index de2349a9a3f..bb23331c151 100644 --- a/src/doc/en/thematic_tutorials/coercion_and_categories.rst +++ b/src/doc/en/thematic_tutorials/coercion_and_categories.rst @@ -105,7 +105,7 @@ it makes sense to build on top of the base class This base class provides a lot more methods than a general parent:: sage: [p for p in dir(Field) if p not in dir(Parent)] - ['__fraction_field', + ['_CommutativeRing__fraction_field', '__iter__', '__len__', '__rxor__', diff --git a/src/sage/arith/srange.pyx b/src/sage/arith/srange.pyx index 156e548a11a..132cf93d085 100644 --- a/src/sage/arith/srange.pyx +++ b/src/sage/arith/srange.pyx @@ -84,7 +84,7 @@ def xsrange(start, end=None, step=1, universe=None, *, coerce=True, bint include EXAMPLES:: sage: xsrange(10) - + <...generator object at 0x...> sage: for i in xsrange(1,5): ....: print(i) 1 diff --git a/src/sage/combinat/sloane_functions.py b/src/sage/combinat/sloane_functions.py index c3cf9299093..e5c99b71fe7 100644 --- a/src/sage/combinat/sloane_functions.py +++ b/src/sage/combinat/sloane_functions.py @@ -9169,7 +9169,7 @@ def __getattribute__(self, name): :: sage: sloane.__repr__ - + sage: sloane.__name__ Traceback (most recent call last): ... diff --git a/src/sage/ext/stdsage.pxd b/src/sage/ext/stdsage.pxd index 15abe13b7cd..e2bf7434f35 100644 --- a/src/sage/ext/stdsage.pxd +++ b/src/sage/ext/stdsage.pxd @@ -10,7 +10,7 @@ Standard C helper code for Cython modules # http://www.gnu.org/licenses/ #***************************************************************************** -from cpython.object cimport Py_TYPE, PyTypeObject +from cpython.object cimport Py_TYPE, PyTypeObject, PyObject cdef inline PY_NEW(type t): @@ -19,7 +19,7 @@ cdef inline PY_NEW(type t): :class:`Integer` where we change ``tp_new`` at runtime (Cython optimizations assume that ``tp_new`` doesn't change). """ - return (t).tp_new(t, NULL, NULL) + return (t).tp_new(t, NULL, NULL) cdef inline void PY_SET_TP_NEW(type dst, type src): diff --git a/src/sage/matrix/matrix_gfpn_dense.pyx b/src/sage/matrix/matrix_gfpn_dense.pyx index 49a556ba7d4..4cccf473de1 100644 --- a/src/sage/matrix/matrix_gfpn_dense.pyx +++ b/src/sage/matrix/matrix_gfpn_dense.pyx @@ -55,7 +55,7 @@ from sage.misc.randstate import current_randstate from sage.misc.randstate cimport randstate from sage.structure.element cimport Element, Matrix from sage.structure.richcmp import rich_to_bool -from .args cimport MatrixArgs_init +from sage.matrix.args cimport MatrixArgs_init from libc.string cimport memset, memcpy diff --git a/src/sage/misc/cachefunc.pyx b/src/sage/misc/cachefunc.pyx index 8aa30a85272..2b1d38c12b9 100644 --- a/src/sage/misc/cachefunc.pyx +++ b/src/sage/misc/cachefunc.pyx @@ -50,7 +50,7 @@ be used:: sage: cython('''cpdef test_funct(x): return -x''') sage: wrapped_funct = cached_function(test_funct, name='wrapped_funct') sage: wrapped_funct - Cached version of + Cached version of sage: wrapped_funct.__name__ 'wrapped_funct' sage: wrapped_funct(5) @@ -82,9 +82,9 @@ approach is still needed for cpdef methods:: sage: cython(os.linesep.join(cython_code)) sage: O = MyClass() sage: O.direct_method - Cached version of + Cached version of sage: O.wrapped_method - Cached version of + Cached version of sage: O.wrapped_method.__name__ 'wrapped_method' sage: O.wrapped_method(5) @@ -270,6 +270,7 @@ Introspection works:: "some doc for a wrapped cython method" return -x sage: print(sage_getsource(O.direct_method)) + @cached_method def direct_method(self, x): "Some doc for direct method" return 2*x diff --git a/src/sage/misc/cython.py b/src/sage/misc/cython.py index 5f83f585c3a..347b2e896d8 100644 --- a/src/sage/misc/cython.py +++ b/src/sage/misc/cython.py @@ -21,6 +21,7 @@ import builtins import os +import re import sys import shutil @@ -396,6 +397,12 @@ def cython(filename, verbose=0, compile_message=False, raise RuntimeError(cython_messages.strip()) if verbose >= 0: + # triggered by Cython 3 with unpatched cysignals 1.11.2 + cython_messages = re.sub( + "^.*The keyword 'nogil' should appear at the end of the function signature line. " + "Placing it before 'except' or 'noexcept' will be disallowed in a future version of Cython.\n", + "", cython_messages, 0, re.MULTILINE) + sys.stderr.write(cython_messages) sys.stderr.flush() diff --git a/src/sage/misc/lazy_import.pyx b/src/sage/misc/lazy_import.pyx index c33a1e74efd..7fc73407ace 100644 --- a/src/sage/misc/lazy_import.pyx +++ b/src/sage/misc/lazy_import.pyx @@ -1095,7 +1095,7 @@ def lazy_import(module, names, as_=None, *, sage: lazy_import('ppl', 'equation', ....: feature=PythonModule('ppl', spkg='pplpy', type='standard')) sage: equation # needs pplpy - + sage: lazy_import('PyNormaliz', 'NmzListConeProperties', feature=PythonModule('PyNormaliz', spkg='pynormaliz')) # optional - pynormaliz sage: NmzListConeProperties # optional - pynormaliz diff --git a/src/sage/misc/lazy_list.pyx b/src/sage/misc/lazy_list.pyx index ba62c446b69..cd750933860 100644 --- a/src/sage/misc/lazy_list.pyx +++ b/src/sage/misc/lazy_list.pyx @@ -678,7 +678,7 @@ cdef class lazy_list_generic(): sage: from itertools import count sage: from sage.misc.lazy_list import lazy_list sage: iter(lazy_list(count())) - + <...generator object at 0x...> :: diff --git a/src/sage/misc/sageinspect.py b/src/sage/misc/sageinspect.py index 88ac75ea843..29a682e4be9 100644 --- a/src/sage/misc/sageinspect.py +++ b/src/sage/misc/sageinspect.py @@ -76,8 +76,8 @@ sage: sage_getdoc(sage.rings.rational.make_rational).lstrip() 'Make a rational number ...' - sage: sage_getsource(sage.rings.rational.make_rational)[4:] - 'make_rational(s):...' + sage: sage_getsource(sage.rings.rational.make_rational) + '@cython.binding(True)\ndef make_rational(s):...' Python functions:: diff --git a/src/sage/modules/free_module_element.pyx b/src/sage/modules/free_module_element.pyx index d5e8256b68c..c9af9bcbdf7 100644 --- a/src/sage/modules/free_module_element.pyx +++ b/src/sage/modules/free_module_element.pyx @@ -1634,7 +1634,7 @@ cdef class FreeModuleElement(Vector): # abstract base class sage: v = vector([1,2/3,pi]) # needs sage.symbolic sage: v.items() # needs sage.symbolic - + <...generator object at ...> sage: list(v.items()) # needs sage.symbolic [(0, 1), (1, 2/3), (2, pi)] diff --git a/src/sage/rings/finite_rings/finite_field_base.pyx b/src/sage/rings/finite_rings/finite_field_base.pyx index 7e2eed91153..3a6db8995c6 100644 --- a/src/sage/rings/finite_rings/finite_field_base.pyx +++ b/src/sage/rings/finite_rings/finite_field_base.pyx @@ -328,7 +328,7 @@ cdef class FiniteField(Field): sage: p = next_prime(2^64) sage: k. = FiniteField(p^2, impl="pari") sage: it = iter(k); it - + <...generator object at ...> sage: [next(it) for i in range(10)] [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] diff --git a/src/sage/rings/polynomial/skew_polynomial_finite_field.pyx b/src/sage/rings/polynomial/skew_polynomial_finite_field.pyx index 41951687939..c6b67cba5fb 100644 --- a/src/sage/rings/polynomial/skew_polynomial_finite_field.pyx +++ b/src/sage/rings/polynomial/skew_polynomial_finite_field.pyx @@ -629,7 +629,7 @@ cdef class SkewPolynomial_finite_field_dense(SkewPolynomial_finite_order_dense): sage: S. = k['x',Frob] sage: a = x^4 + 2*t*x^3 + 3*t^2*x^2 + (t^2 + t + 1)*x + 4*t + 3 sage: iter = a.right_irreducible_divisors(); iter - + <...generator object at 0x...> sage: next(iter) # random x + 2*t^2 + 4*t + 4 sage: next(iter) # random @@ -664,7 +664,7 @@ cdef class SkewPolynomial_finite_field_dense(SkewPolynomial_finite_order_dense): sage: S. = k['x',Frob] sage: a = x^4 + 2*t*x^3 + 3*t^2*x^2 + (t^2 + t + 1)*x + 4*t + 3 sage: iter = a.left_irreducible_divisors(); iter - + <...generator object at 0x...> sage: next(iter) # random x + 3*t + 3 sage: next(iter) # random @@ -1052,7 +1052,7 @@ cdef class SkewPolynomial_finite_field_dense(SkewPolynomial_finite_order_dense): sage: S. = k['x',Frob] sage: a = x^3 + (t^2 + 1)*x^2 + (2*t + 3)*x + t^2 + t + 2 sage: iter = a.factorizations(); iter - + <...generator object at 0x...> sage: next(iter) # random (x + 3*t^2 + 4*t) * (x + 2*t^2) * (x + 4*t^2 + 4*t + 2) sage: next(iter) # random diff --git a/src/sage/structure/coerce_dict.pyx b/src/sage/structure/coerce_dict.pyx index a2e8443084c..ef86c6af35c 100644 --- a/src/sage/structure/coerce_dict.pyx +++ b/src/sage/structure/coerce_dict.pyx @@ -777,7 +777,7 @@ cdef class MonoDict: sage: L[1] = None sage: L[2] = True sage: L.items() - + <...generator object at ...> sage: sorted(L.items()) [(1, None), (2, True)] """ @@ -1452,7 +1452,7 @@ cdef class TripleDict: sage: L = TripleDict() sage: L[1,2,3] = None sage: L.items() - + <...generator object at ...> sage: list(L.items()) [((1, 2, 3), None)] """ diff --git a/src/sage/tests/cmdline.py b/src/sage/tests/cmdline.py index ad0c44aa274..f14cd2db768 100644 --- a/src/sage/tests/cmdline.py +++ b/src/sage/tests/cmdline.py @@ -491,9 +491,8 @@ def test_executable(args, input="", timeout=100.0, pydebug_ignore_warnings=False sage: (out, err, ret) = test_executable(["sage", "--cython"]) sage: print(err) - Cython (http://cython.org) is a compiler for code written in the - Cython language. Cython is based on Pyrex by Greg Ewing. ... + cython: error: cython: Need at least one source file sage: def has_tty(): ....: try: diff --git a/src/sage_setup/cython_options.py b/src/sage_setup/cython_options.py index 086aa070ca9..9725ce0e1af 100644 --- a/src/sage_setup/cython_options.py +++ b/src/sage_setup/cython_options.py @@ -10,13 +10,17 @@ def compiler_directives(profile: bool): auto_pickle=False, # Do not create __test__ dictionary automatically from docstrings autotestdict=False, + binding=False, + c_api_binop_methods=True, # Do not check for division by 0 (this is about 35% quicker than with check) cdivision=True, + cpow=True, # Embed a textual copy of the call signature in the docstring (to support tools like IPython) embedsignature=True, fast_getattr=True, # Use Python 3 (including source code semantics) for module compilation language_level="3", + legacy_implicit_noexcept=True, # Enable support for late includes (make declarations in Cython code available to C include files) preliminary_late_includes_cy28=True, # Add hooks for Python profilers into the compiled C code