Magic Cython compiling doesn't display errors

41 views
Skip to first unread message

Travis Scrimshaw

unread,
Feb 4, 2026, 9:09:10 AM (21 hours ago) Feb 4
to sage-devel
It just does this:

tscrim@travis-apricot:~$ sage
Traceback (most recent call last):
  File "/home/tscrim/sage/local/var/lib/sage/venv-python3.12.5/lib/python3.12/site-packages/_sagemath_editable_loader.py", line 345, in _rebuild
    subprocess.run(self._build_cmd, cwd=self._build_path, env=env, stdout=subprocess.DEVNULL, check=True)
  File "/home/tscrim/sage/local/var/lib/sage/venv-python3.12.5/lib/python3.12/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/usr/bin/ninja']' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/tscrim/sage/src/bin/sage-ipython", line 9, in <module>
    from sage.misc.banner import banner
  File "/home/tscrim/sage/local/var/lib/sage/venv-python3.12.5/lib/python3.12/site-packages/_sagemath_editable_loader.py", line 311, in find_spec
    tree = self._rebuild()
           ^^^^^^^^^^^^^^^
  File "/home/tscrim/sage/local/var/lib/sage/venv-python3.12.5/lib/python3.12/site-packages/_sagemath_editable_loader.py", line 347, in _rebuild
    raise ImportError(f're-building the {self._name} meson-python editable wheel package failed') from exc
ImportError: re-building the sagemath meson-python editable wheel package failed

Thus I cannot debug Cython errors unless I run "sage -b", which takes forever because the meson setup takes multiple minutes every time.

Two things we (specifically the people changing stuff in the build system) **really** need to do because this is unsustainable for Cython development in Sage:

1) Figure out what makes meson take so long to do its thing each time "sage -b" is run because this significantly slows many things down.
2a) Display the error message when cython builds fail so we can debug cython errors with the magic compiling. (I still *very* strongly believe we should give a message saying Cython code is recompiling verbosely on the files so it doesn't look like it is hanging. I also believe it is bad practice to make a non-jit-compiled language act like a jit-compiled language, but that is secondary.)
2b) Revert "sage -b" to actually just rebuilding the parts of Sage that should be rebuilt/recompiled; meson is not part of this AFAIK.

Travis

Tobia...@gmx.de

unread,
Feb 4, 2026, 9:57:21 AM (20 hours ago) Feb 4
to sage-devel
You can try the verbose mode by setting the env variable `MESONPY_EDITABLE_VERBOSE`, see https://mesonbuild.com/meson-python/how-to-guides/editable-installs.html#verbose-mode

Ad 1: it's the documentation build. This should be fixed by https://github.com/sagemath/sage/pull/41156 and https://github.com/sagemath/sage/pull/41162 but I currently don't have much time to work on this myself. So help eg in the form of PRs against the PR-branch is very welcome.

Dima Pasechnik

unread,
Feb 4, 2026, 11:20:54 AM (19 hours ago) Feb 4
to sage-...@googlegroups.com, Travis Scrimshaw
On February 4, 2026 8:57:21 AM CST, "'Tobia...@gmx.de' via sage-devel" <sage-...@googlegroups.com> wrote:
You can try the verbose mode by setting the env variable `MESONPY_EDITABLE_VERBOSE`, see https://mesonbuild.com/meson-python/how-to-guides/editable-installs.html#verbose-mode

Ad 1: it's the documentation build. This should be fixed by https://github.com/sagemath/sage/pull/41156 and https://github.com/sagemath/sage/pull/41162 but I currently don't have much time to work on this myself. So help eg in the form of PRs against the PR-branch is very welcome.

indeed, "export MESONPY_EDITABLE_VERBOSE=1" should make building more verbose
Also, after https://github.com/sagemath/sage/pull/41418 (should be in the latest betas)
./configure --disable-doc
will make rebuilding much quicker (the time was wasted otherwise in meson scanning documents in src/doc)
tells "sage -b" to run menson directly

Regarding the build logs. Meson logs are in build/sage-distro/meson-logs/
and ninja logs are in  build/sage-distro/.ninja_log


 

On Wednesday, February 4, 2026 at 3:09:10 PM UTC+1 tcsc...@gmail.com wrote:
It just does this:

tscrim@travis-apricot:~$ sage
Traceback (most recent call last):
  File "/home/tscrim/sage/local/var/lib/sage/venv-python3.12.5/lib/python3.12/site-packages/_sagemath_editable_loader.py", line 345, in _rebuild
    subprocess.run(self._build_cmd, cwd=self._build_path, env=env, stdout=subprocess.DEVNULL, check=True)
  File "/home/tscrim/sage/local/var/lib/sage/venv-python3.12.5/lib/python3.12/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/usr/bin/ninja']' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/tscrim/sage/src/bin/sage-ipython", line 9, in <module>
    from sage.misc.banner import banner
  File "/home/tscrim/sage/local/var/lib/sage/venv-python3.12.5/lib/python3.12/site-packages/_sagemath_editable_loader.py", line 311, in find_spec
    tree = self._rebuild()
           ^^^^^^^^^^^^^^^
  File "/home/tscrim/sage/local/var/lib/sage/venv-python3.12.5/lib/python3.12/site-packages/_sagemath_editable_loader.py", line 347, in _rebuild
    raise ImportError(f're-building the {self._name} meson-python editable wheel package failed') from exc
ImportError: re-building the sagemath meson-python editable wheel package failed

Thus I cannot debug Cython errors unless I run "sage -b", which takes forever because the meson setup takes multiple minutes every time.

Two things we (specifically the people changing stuff in the build system) **really** need to do because this is unsustainable for Cython development in Sage:

1) Figure out what makes meson take so long to do its thing each time "sage -b" is run because this significantly slows many things down.
2a) Display the error message when cython builds fail so we can debug cython errors with the magic compiling. (I still *very* strongly believe we should give a message saying Cython code is recompiling verbosely on the files so it doesn't look like it is hanging. I also believe it is bad practice to make a non-jit-compiled language act like a jit-compiled language, but that is secondary.)
this is  "export MESONPY_EDITABLE_VERBOSE=1"

2b) Revert "sage -b" to actually just rebuilding the parts of Sage that should be rebuilt/recompiled; meson is not part of this AFAIK.
"sage -b" does

ninja -C $SAGE_ROOT/build/sage-distro 

(you can also run this explictly)

Tobias says it's not 100% fool-proof from meson point of view, but it's certainly fast and should very quickly rebuild 
what's needed.

Dima


Travis

Travis Scrimshaw

unread,
Feb 4, 2026, 9:39:43 PM (9 hours ago) Feb 4
to sage-devel
Okay, thanks. That helped a lot and made it so I could fix my compile-time issues.

That said, there is absolutely *no* way anybody except a sage build system expert could have found and known to do that. Also, I had no idea I should even look at meson/ninja logs for cython errors (much less where they would be located) either.

We need proper displaying of error messages when builds fail. The generic slop I posted is completely unhelpful (thankfully, I knew it was a Cython compile issue because of what I was changing, but imagine if I didn't; e.g., a bad branch merge). There is a balance to be had, but we need more general verbosity in starting Sage when its running (potentially time consuming) build steps.

Unfortunately I don't even have enough time to do the code I really need to do (even more so for should), nor do I have the expertise to help with the build system stuff.


That's good to hear at least.

Best,
Travis 
Reply all
Reply to author
Forward
0 new messages