Meson build

121 views
Skip to first unread message

enriqu...@gmail.com

unread,
Aug 15, 2025, 9:49:23 AMAug 15
to sage-devel
In order to check https://github.com/sagemath/sage/pull/40555 I am trying to build sage with meson. I try to follow the instructions for 10.7 but I find some issues. I would appreciate some help that eventually may lead to improve the documentation. 
Before starting, if one copies the instructions in html, it is OK when in the rst the instruction
is written in the file but $ is typed when it is an instruction following .. literalinclude

I use the instructions for "Using system package manager". There is a warning after " uv pip install": 
warning: Failed to hardlink files; falling back to full copy. This may lead to degraded performance.
        If the cache and target directories are on different filesystems, hardlinking may not be supported.
        If this is intentional, set `export UV_LINK_MODE=copy` or use `--link-mode=copy` to suppress this warning.
I do not know  if this important. By the way should "--editable" should be added here of somewhere.
For "uv sync --frozen --inexact --no-build-isolation" I get the error in the attached file.

Thanks for reading. Enrique.

meson.log

Tobia...@gmx.de

unread,
Aug 15, 2025, 12:33:14 PMAug 15
to sage-devel
Thanks a lot for giving this a try!

 
Before starting, if one copies the instructions in html, it is OK when in the rst the instruction
is written in the file but $ is typed when it is an instruction following .. literalinclude

I'm not sure I follow completely. It works correctly if you copy from the website, but not when you copy the $ that is in the rst file?
 

I use the instructions for "Using system package manager". There is a warning after " uv pip install": 
warning: Failed to hardlink files; falling back to full copy. This may lead to degraded performance.
        If the cache and target directories are on different filesystems, hardlinking may not be supported.
        If this is intentional, set `export UV_LINK_MODE=copy` or use `--link-mode=copy` to suppress this warning.

It's safe to ignore that warning. If you still want to fix it, you can use  uv cache dir so see the current cache dir, and then set the  UV_CACHE_DIR env variable to the same disc as the sage project.
 

I do not know  if this important. By the way should "--editable" should be added here of somewhere.

uv automatically uses editable install, unless told otherwise.
 
For "uv sync --frozen --inexact --no-build-isolation" I get the error in the attached file.

These are coming from some issues with the older cypari. I've updated it in https://github.com/sagemath/sage/pull/40592, could you please give this a try? Thanks! 

Dima Pasechnik

unread,
Aug 15, 2025, 2:07:05 PMAug 15
to sage-...@googlegroups.com
If you already done a classic build, then you don't need uv to do a meson build of sagelib.
Just start

./sage --buildsh

followed by meson commands as specified in the manual. Say, to have the meson builddir  cp3, do

  meson setup cp3

and then follow the meson commands in the manual
(meson compile, etc)

At the end your ./sage will be switched to using the meson-built sagelib, which you can test and use as usual.

enriqu...@gmail.com

unread,
Aug 16, 2025, 10:51:25 AMAug 16
to sage-devel
El viernes, 15 de agosto de 2025 a las 18:33:14 UTC+2, Tobia...@gmx.de escribió:
Thanks a lot for giving this a try!
Thanks to all of you for your really hard work. 

Before starting, if one copies the instructions in html, it is OK when in the rst the instruction
is written in the file but $ is typed when it is an instruction following .. literalinclude

I'm not sure I follow completely. It works correctly if you copy from the website, but not when you copy the $ that is in the rst file?

Sorry for my poor explanations. I try to do better with concrete examples.

If I use the first button "Copy to clipboard" in the file, I get: 

mamba env create --file environment-3.12-linux.yml --name sage-dev
mamba activate sage-dev

Pasted in terminal is OK. By the way, the next block "pip install –no-build-isolation –editable ." has no such button. As a consequence – is copied instead of --.

If I use the next button (say the Fedora part) the $ character is also copied and the copied text gives an error in the terminal because of the $; it is not a big deal but I guess it can be solved easily. 

In the same way, in the button of the block starting with "uv venv", only three lines are copied (first, second and last). Again as above, it is not a ...

 

These are coming from some issues with the older cypari. I've updated it in https://github.com/sagemath/sage/pull/40592, could you please give this a try? Thanks! 
Patching the files in this PR,  the command works, but ./sage fails with:

Traceback (most recent call last):
 File "/usr/local/sagemeson/src/bin/sage-ipython", line 9, in <module>
   from sage.misc.banner import banner
ModuleNotFoundError: No module named 'sage'

I did a guess and used "pip install --no-build-isolation --editable ." but failed, see the attachment. It seems the issue comes from brial which is not anymore a package in fedora.
meson-log.txt

enriqu...@gmail.com

unread,
Aug 16, 2025, 11:25:00 AMAug 16
to sage-devel
Thanks! My first remark is that it would be nice to have this in the documentation. The second point is that a classic build takes a while building sagelib. Is there a way to avoid this building and then perform a meson build of sagelib?
Following your instructions in a classical build I did a meson build of sagelib (though I forgot the install part). I uninstalled sirocco and sagemath_sirocco, and fundamental groups did not work. Applying ./configure --enable-sirocco and make sirocco, the computations worked!
Thanks, Enrique.

Tobia...@gmx.de

unread,
Aug 17, 2025, 8:43:35 AMAug 17
to sage-devel
Thanks for the explanation. In https://github.com/sagemath/sage/pull/40609, I've tried to fix the small bugs in the docs that you pointed out. However, 

> If I use the next button (say the Fedora part) the $ character is also copied and the copied text gives an error in the terminal because of the $; it is not a big deal but I guess it can be solved easily. 
> In the same way, in the button of the block starting with "uv venv", only three lines are copied (first, second and last). Again as above, it is not a ...

seem to be actually bugs in sphinx (or I cannot figure out why the copy button works in such a strange way there).

For the build issue, it's actually coming from

Traceback (most recent call last):
  File "/usr/local/sagemeson/src/build-docs.py", line 8, in <module>
    from sage_docbuild.__main__ import main
  File "/usr/local/sagemeson/src/sage_docbuild/__main__.py", line 81, in <module>
    import sphinx.ext.intersphinx
  File "/home/artal/.local/lib/python3.13/site-packages/sphinx/ext/intersphinx.py", line 37, in <module>
    from sphinx.builders.html import INVENTORY_FILENAME
  File "/home/artal/.local/lib/python3.13/site-packages/sphinx/builders/html/__init__.py", line 45, in <module>
    from sphinx.writers.html import HTMLTranslator, HTMLWriter
  File "/home/artal/.local/lib/python3.13/site-packages/sphinx/writers/html.py", line 21, in <module>
    from sphinx.util.images import get_image_size
  File "/home/artal/.local/lib/python3.13/site-packages/sphinx/util/images.py", line 4, in <module>
    import imghdr
ModuleNotFoundError: No module named 'imghdr'

That is a result of a too-old sphinx, which is not compatible with python 3.13. After you update sphinx, the build should work.

Finally, I should note that with https://github.com/sagemath/sage/pull/39030 sage-the-distro will also use the meson build of sagelib.

enriqu...@gmail.com

unread,
Sep 2, 2025, 1:24:30 PM (2 days ago) Sep 2
to sage-devel
I have probably some silly questions concerning meson installation but I has been unable to find the answers:
- Using conda, how can one install optional packages?
- Using system packages, how can I install a package with a higher version?
Thanks, Enrique.

Dima Pasechnik

unread,
Sep 2, 2025, 3:29:58 PM (2 days ago) Sep 2
to sage-...@googlegroups.com
On Tue, Sep 2, 2025 at 12:24 PM enriqu...@gmail.com
<enriqu...@gmail.com> wrote:
>
> I have probably some silly questions concerning meson installation but I has been unable to find the answers:

Are to talking about #39030, or about the direct "pip install" of sagemath?

For the former, there should be no (perhaps for the time being
sage_setup might have to be installed for some
optional/external packages)

> - Using conda, how can one install optional packages?
Do you mean conda-managed packages?

> - Using system packages, how can I install a package with a higher version?
in #39030, there should be no difference w.r.t. the current workflow.
Otherwise, pip install ?

Dima
> --
> You received this message because you are subscribed to the Google Groups "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/sage-devel/44992448-b779-480f-8c15-47e601bcde0dn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages