cschwan / sage-on-gentoo

(Unofficial) Gentoo Overlay for Sage- and Sage-related ebuilds
80 stars 26 forks source link

cython 3.0.11 breaks building sagemath-standard #794

Open kiwifb opened 1 month ago

kiwifb commented 1 month ago

As the title says. The final error is reminiscent of #783 but in the end quite different in its causes.

  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/lib/python3.12/site-packages/gpep517/__main__.py", line 443, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/lib/python3.12/site-packages/gpep517/__main__.py", line 439, in main
    return func(args)
           ^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/gpep517/__main__.py", line 229, in build_wheel
    print(build_wheel_impl(args, args.wheel_dir), file=out)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/gpep517/__main__.py", line 221, in build_wheel_impl
    wheel_name = backend.build_wheel(str(wheel_dir), args.config_json)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/setuptools/build_meta.py", line 415, in build_wheel
    return self._build_with_temp_dir(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/setuptools/build_meta.py", line 397, in _build_with_temp_dir
    self.run_setup()
  File "/usr/lib/python3.12/site-packages/setuptools/build_meta.py", line 313, in run_setup
    exec(code, locals())
  File "<string>", line 95, in <module>
  File "/usr/lib/python3.12/site-packages/setuptools/__init__.py", line 108, in setup
    return distutils.core.setup(**attrs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/setuptools/_distutils/core.py", line 184, in setup
    return run_commands(dist)
           ^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/setuptools/_distutils/core.py", line 200, in run_commands
    dist.run_commands()
  File "/usr/lib/python3.12/site-packages/setuptools/_distutils/dist.py", line 970, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python3.12/site-packages/setuptools/dist.py", line 956, in run_command
    super().run_command(command)
  File "/usr/lib/python3.12/site-packages/setuptools/_distutils/dist.py", line 989, in run_command
    cmd_obj.run()
  File "/usr/lib/python3.12/site-packages/setuptools/command/bdist_wheel.py", line 373, in run
    self.run_command("build")
  File "/usr/lib/python3.12/site-packages/setuptools/_distutils/cmd.py", line 316, in run_command
    self.distribution.run_command(command)
  File "/usr/lib/python3.12/site-packages/setuptools/dist.py", line 956, in run_command
    super().run_command(command)
  File "/usr/lib/python3.12/site-packages/setuptools/_distutils/dist.py", line 989, in run_command
    cmd_obj.run()
  File "/usr/lib/python3.12/site-packages/setuptools/_distutils/command/build.py", line 135, in run
    self.run_command(cmd_name)
  File "/usr/lib/python3.12/site-packages/setuptools/_distutils/cmd.py", line 316, in run_command
    self.distribution.run_command(command)
  File "/usr/lib/python3.12/site-packages/setuptools/dist.py", line 956, in run_command
    super().run_command(command)
  File "/usr/lib/python3.12/site-packages/setuptools/_distutils/dist.py", line 989, in run_command
    cmd_obj.run()
  File "/usr/lib/python3.12/site-packages/sage_setup/command/sage_build_ext.py", line 25, in run
    self.run_command('build_cython')
  File "/usr/lib/python3.12/site-packages/setuptools/_distutils/cmd.py", line 316, in run_command
    self.distribution.run_command(command)
  File "/usr/lib/python3.12/site-packages/setuptools/dist.py", line 956, in run_command
    super().run_command(command)
  File "/usr/lib/python3.12/site-packages/setuptools/_distutils/dist.py", line 989, in run_command
    cmd_obj.run()
  File "/usr/lib/python3.12/site-packages/sage_setup/command/sage_build_cython.py", line 220, in run
    extensions = cythonize(
                 ^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/Cython/Build/Dependencies.py", line 1150, in cythonize
    result.get(99999)  # seconds
    ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/multiprocessing/pool.py", line 774, in get
    raise self._value
Cython.Compiler.Errors.CompileError: sage/matroids/circuit_closures_matroid.pyx

but in fact this starts much earlier during cythonizing


Error compiling Cython file:
------------------------------------------------------------
...
        """
        self._pack(self._input, F)
        self.__max_independent(self._output, self._input)
        return self.__unpack(self._output)

    cpdef int _rank(self, frozenset F):
          ^
------------------------------------------------------------

sage/matroids/basis_exchange_matroid.pyx:655:10: Signature not compatible with previous declaration

Error compiling Cython file:
------------------------------------------------------------
...
    cdef int _stored_full_rank
    cdef int _stored_size

    # virtual methods
    cpdef frozenset groundset(self)
    cpdef int _rank(self, frozenset X)
                   ^
------------------------------------------------------------

sage/matroids/matroid.pxd:12:19: Previous declaration is here
warning: sage/matroids/basis_exchange_matroid.pyx:799:21: Implicit noexcept declaration is deprecated. Function declaration should contain 'noexcept' keyword.

Error compiling Cython file:
------------------------------------------------------------
...
        """
        self._pack(self._input, F)
        self.__max_coindependent(self._output, self._input)
        return self.__unpack(self._output)

    cpdef int _corank(self, frozenset F):
          ^
------------------------------------------------------------

sage/matroids/basis_exchange_matroid.pyx:799:10: Signature not compatible with previous declaration

Error compiling Cython file:
------------------------------------------------------------
...
    # internal methods, assuming verified input
    cpdef frozenset _max_independent(self, frozenset X)
    cpdef frozenset _circuit(self, frozenset X)
    cpdef frozenset _fundamental_circuit(self, frozenset B, e)
    cpdef frozenset _closure(self, frozenset X)
    cpdef int _corank(self, frozenset X)
                     ^
------------------------------------------------------------

sage/matroids/matroid.pxd:19:21: Previous declaration is here
warning: sage/matroids/basis_exchange_matroid.pyx:943:30: Implicit noexcept declaration is deprecated. Function declaration should contain 'noexcept' keyword.

Error compiling Cython file:
------------------------------------------------------------
...
        self._pack(self._input, X)
        self._pack(self._input2, Y)
        self.__augment(self._output, self._input, self._input2)
        return self.__unpack(self._output)

    cpdef bint _is_independent(self, frozenset F):
          ^
------------------------------------------------------------

sage/matroids/basis_exchange_matroid.pyx:943:10: Signature not compatible with previous declaration

Error compiling Cython file:
------------------------------------------------------------
...
    cpdef frozenset _cocircuit(self, frozenset X)
    cpdef frozenset _fundamental_cocircuit(self, frozenset B, e)
    cpdef frozenset _coclosure(self, frozenset X)
    cpdef frozenset _augment(self, frozenset X, frozenset Y)

    cpdef bint _is_independent(self, frozenset X)
                              ^
------------------------------------------------------------

sage/matroids/matroid.pxd:26:30: Previous declaration is here
warning: sage/matroids/basis_exchange_matroid.pyx:2234:23: Implicit noexcept declaration is deprecated. Function declaration should contain 'noexcept' keyword.

Error compiling Cython file:
------------------------------------------------------------
...
            if self.__is_isomorphism(other, morphism):
                return True

        return self._characteristic_setsystem()._isomorphism(other._characteristic_setsystem(), PS, PO) is not None

    cpdef bint is_valid(self):
          ^
------------------------------------------------------------

sage/matroids/basis_exchange_matroid.pyx:2234:10: Signature not compatible with previous declaration

Error compiling Cython file:
------------------------------------------------------------
...
    cpdef is_cobasis(self, X)
    cpdef is_cocircuit(self, X)
    cpdef is_coclosed(self, X)

    # verification
    cpdef bint is_valid(self)
                       ^
------------------------------------------------------------

sage/matroids/matroid.pxd:108:23: Previous declaration is here
warning: sage/matroids/circuit_closures_matroid.pyx:182:19: Implicit noexcept declaration is deprecated. Function declaration should contain 'noexcept' keyword.

Error compiling Cython file:
------------------------------------------------------------
...
            sage: sorted(M.groundset())
            ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i']
        """
        return frozenset(self._groundset)

    cpdef int _rank(self, frozenset X):
          ^
------------------------------------------------------------

sage/matroids/circuit_closures_matroid.pyx:182:10: Signature not compatible with previous declaration

Error compiling Cython file:
------------------------------------------------------------
...
    cdef int _stored_full_rank
    cdef int _stored_size

    # virtual methods
    cpdef frozenset groundset(self)
    cpdef int _rank(self, frozenset X)
                   ^
------------------------------------------------------------

sage/matroids/matroid.pxd:12:19: Previous declaration is here
warning: sage/matroids/circuit_closures_matroid.pyx:224:30: Implicit noexcept declaration is deprecated. Function declaration should contain 'noexcept' keyword.

Error compiling Cython file:
------------------------------------------------------------
...
            sage: M.dual().full_rank()
            4
        """
        return self._matroid_rank

    cpdef bint _is_independent(self, frozenset F):
          ^
------------------------------------------------------------

sage/matroids/circuit_closures_matroid.pyx:224:10: Signature not compatible with previous declaration

Error compiling Cython file:
------------------------------------------------------------
...
    cpdef frozenset _cocircuit(self, frozenset X)
    cpdef frozenset _fundamental_cocircuit(self, frozenset B, e)
    cpdef frozenset _coclosure(self, frozenset X)
    cpdef frozenset _augment(self, frozenset X, frozenset Y)

    cpdef bint _is_independent(self, frozenset X)
                              ^
------------------------------------------------------------

sage/matroids/matroid.pxd:26:30: Previous declaration is here
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/Cython/Build/Dependencies.py", line 1350, in cythonize_one_helper
    return cythonize_one(*m)
           ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/Cython/Build/Dependencies.py", line 1326, in cythonize_one
    raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: sage/matroids/circuit_closures_matroid.pyx

this works perfectly with cython 3.0.10.

kiwifb commented 1 month ago

Similar cython errors show up in sage/matroids/flats_matroid.pyx, sage/matroids/matroid.pyx, sage/matroids/union_matroid.pyx, sage/matroids/graphic_matroid.pyx, sage/matroids/linear_matroid.pyx and sage/sets/disjoint_set.pyx

kiwifb commented 1 month ago

And sage/matroids/basis_exchange_matroid.pyx. I cannot exclude missing a few others.

strogdon commented 4 weeks ago

sage with cython-3.0.11 and the regression patch https://github.com/void-linux/void-packages/commit/b5926bd0342911d1547f37a862082ab73ee1644e does build. However, the regression patch does not appear under https://github.com/cython/cython/commits/master/

kiwifb commented 4 weeks ago

I have a patch in the vbraun branch and we are working on something a bit better upstream. sage needs to get rid of those things anyway. Fun fact, cypari2 from the main tree is also failing to build with cython 3.0.11 from the tree - 2.2.0 which I am pushing, does not have the problem.

kiwifb commented 1 week ago

OK, my work on getting cython 3.0.11 to work with sage is merged and officially out in the current dev branch. I am experimenting with a new way to distribute patches from upstream PR so once I merge my current development branch sage 10.4 will have support for cython 3.0.11 (you may have to update cypari2 to 2.0.0 as well). The way I distribute the patch is experimental, report issues please The merge will be done in the next hour.

strogdon commented 1 week ago

After a length system update I see:

 * Applying sagemath-standard-10.4b-neutering.patch ...
 [ ok ]
 * Build system packages:
 *   dev-python/gpep517            : 16
 *   dev-python/installer          : 0.7.0
 *   dev-python/cython             : 3.0.11
 *   dev-python/setuptools         : 72.2.0
 *   dev-python/setuptools-rust    : 1.10.1
 *   dev-python/setuptools-scm     : 8.1.0
 *   dev-python/wheel              : 0.44.0
/var/tmp/portage/sci-mathematics/sagemath-standard-9999/temp/environment: line 4998: /var/tmp/portage/sci-mathematics/sagemath-standard-9999/distdir/38113_proc.patch: Permission denied
 * ERROR: sci-mathematics/sagemath-standard-9999::sage-on-gentoo failed (prepare phase):
 *   patch for PR 38113 not found
 * 
 * Call stack:
 *     ebuild.sh, line  136:  Called src_prepare
 *   environment, line 5046:  Called distutils-r1_src_prepare
 *   environment, line 2211:  Called python_prepare_all
 *   environment, line 4815:  Called sage-git-patch_patch
 *   environment, line 4998:  Called die
 * The specific snippet of code:
 *           filterdiff -i '*/${tree}/*' "${DISTDIR}/sagemath_PR${patch}.patch" > "${DISTDIR}/${patch}_proc.patch" || die "patch for PR ${patch} not found";

Perhaps the patch file had been misnamed?

# ls -al /var/tmp/portage/sci-mathematics/sagemath-standard-9999/distdir/
total 2
drwxr-xr-x 2 root    portage 1024 Sep  4 14:52 .
drwx------ 8 portage portage 1024 Sep  4 14:53 ..
lrwxrwxrwx 1 root    root      43 Sep  4 14:52 sagemath_PR38113.patch -> /var/cache/distfiles/sagemath_PR38113.patch
kiwifb commented 1 week ago

Looks like I may have done something stupid, but I should have caught it. Let me check all that.

kiwifb commented 1 week ago

Yes, I try to process the patch somewhere I should not have. I need to update the eclass.

kiwifb commented 1 week ago

OK, I have updated the eclass, it should take about 15mn for the gentoo mirror to update.

strogdon commented 1 week ago

sagemath-standard-9999 now builds but sage-doc-9999 fails.