Skip to content

Conversation

tobiasdiez
Copy link
Contributor

Adds a CI for meson on top of gentoo and adds a correpsonding devcontainer to run the setup locally. The main purpose is to test the build-from-source steps on gentoo (i.e. not the "install sage from the overlay" steps).

📝 Checklist

  • The title is concise and informative.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation and checked the documentation preview.

⌛ Dependencies

@tobiasdiez
Copy link
Contributor Author

Devcontainer currently fails to install cypari2 with

SyntaxWarning: invalid escape sequence '\['
        verb_loop = re.compile("^(    .*)@\[[a-z]*\]", re.MULTILINE)
      /root/.cache/uv/builds-v0/.tmp70O2Lb/lib/python3.13/site-packages/setupto
ols/config/_apply_pyprojecttoml.py:82:
      SetuptoolsDeprecationWarning: `project.license` as a TOML table is
      deprecated

which is fixed in sagemath/cypari2#182.

@tobiasdiez
Copy link
Contributor Author

CI fails with

Use --autounmask-write to write changes to config files (honoring
CONFIG_PROTECT). Carefully examine the list of proposed changes,
paying special attention to mask or keyword changes that may expose
experimental or unstable packages.
 * In order to avoid wasting time, backtracking has terminated early
 * due to the above autounmask change(s). The --autounmask-backtrack=y
 * option can be used to force further backtracking, but there is no
 * guarantee that it will produce a solution.
!!! All ebuilds that could satisfy "media-libs/qhull[tools]" have been masked.
!!! One of the following masked packages is required to complete your request:
- media-libs/qhull-2020.2.8.1_alpha4::gentoo (masked by: ~amd64 keyword)
For more information, see the MASKED PACKAGES section in the emerge
man page or refer to the Gentoo Handbook.

Not sure what's the correct way to resolve it. @kiwifb @orlitzky

@kiwifb
Copy link
Member

kiwifb commented Aug 22, 2025

The only version of qhull available is currently marked "unstable", possibly because no one took the time to stabilize it. We could run the container on the bleeding edge by setting portage to accept the ~amd64 keyword. If not we have to provide a file listing any package in unstable we wish to use.
I have not updated https://github.com/cschwan/sage-on-gentoo/blob/master/tools/docker/dockerfile-devel recently but I should try to move it to meso too.

Copy link

github-actions bot commented Aug 22, 2025

Documentation preview for this PR (built with commit 56d6812; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

@tobiasdiez
Copy link
Contributor Author

tobiasdiez commented Aug 22, 2025

Thanks, I've now added autounmask to see what keyword changes are necessary.

First of all, it complains about:

!!! Multiple package instances within a single package slot have been pulled
!!! into the dependency graph, resulting in a slot conflict:
sci-libs/m4ri:0
  (sci-libs/m4ri-20240729:0/0::gentoo, ebuild scheduled for merge) USE="openmp png -debug" ABI_X86="(64)" CPU_FLAGS_X86="sse2" pulled in by
    sci-libs/m4ri[png] (Argument)
  (sci-libs/m4ri-20250128-r1:0/1::gentoo, ebuild scheduled for merge) USE="openmp -debug -png" ABI_X86="(64)" CPU_FLAGS_X86="sse2" pulled in by
    sci-libs/m4ri[png=] required by (sci-libs/brial-1.2.12:0/0::gentoo, ebuild scheduled for merge) USE="-png" ABI_X86="(64)"
                  ^^^^                                                                                                        
It might be possible to solve this slot collision
by applying all of the following changes:
   - sci-libs/brial-1.2.12 (Change USE: +png)

Should I remove the png part from in https://github.com/sagemath/sage/blob/31030557a5b692d3b1761b64ea1fc4874b3ea654/build/pkgs/m4ri/distros/gentoo.txt or add a similar png tag in https://github.com/sagemath/sage/blob/ad175f60aa5efb8c00b6206e205d7e6fe1acea0b/build/pkgs/brial/distros/gentoo.txt ?

Next it suggests

The following keyword changes are necessary to proceed:
 (see "package.accept_keywords" in the portage(5) man page for more details)
# required by media-gfx/tachyon (argument)
=media-gfx/tachyon-0.99.5 ~amd64
# required by media-libs/qhull[tools] (argument)
=media-libs/qhull-2020.2.8.1_alpha4 ~amd64
# required by sci-libs/m4rie-20250103-r1::gentoo
# required by sci-libs/m4rie (argument)
=sci-libs/m4ri-20250128-r1 ~amd64
The following USE changes are necessary to proceed:
 (see "package.use" in the portage(5) man page for more details)
# required by sci-libs/cddlib[tools] (argument)
>=sci-libs/cddlib-094m-r2 tools
# required by sci-mathematics/eclib[flint] (argument)
>=sci-mathematics/eclib-20250122 flint
# required by sci-mathematics/flint[ntl] (argument)
>=sci-mathematics/flint-3.1.3_p1-r4 ntl
# required by sci-mathematics/lcalc[pari] (argument)
>=sci-mathematics/lcalc-2.0.5-r2 pari
# required by sci-libs/m4ri[png] (argument)
=sci-libs/m4ri-20240729 png
# required by sci-mathematics/maxima[ecl] (argument)
>=sci-mathematics/maxima-5.47.0-r1 ecl
# required by media-libs/qhull[tools] (argument)
>=media-libs/qhull-2020.2.8.1_alpha4 tools
# required by virtual/opengl-8::gentoo
# required by media-gfx/tachyon-0.99.5::gentoo
# required by media-gfx/tachyon (argument)
>=media-libs/libglvnd-1.7.0 X

Is it okay to add those to /etc/portage/package.accept_keywords/sage?

Basically, I'm wondering what steps one should use on Gentoo to build from source (to be added under https://doc-develop--sagemath.netlify.app/html/en/installation/meson#using-system-package-manager)

@orlitzky
Copy link
Contributor

This is going to be hard to keep up to date without a sagemath package in ::gentoo (that devs are somewhat obligated not to break) to pull the deps from.

The qhull thing is because a new USE=tools flag was added to the unstable version of qhull, but the old stable version doesn't have it. This was a Gentoo mistake, but one that happens all the time. The old version, even though it doesn't have USE=tools, always enables the tools. So the old stable version is fine, too. But, if you want to say that sage depends on qhull, now you have to have it depend on qhull[tools], because otherwise you might pull in the unstable version without the flag. This however rules out the old stable version because the flag is not there to satisfy the qhull[tools] dependency. tl;dr the old version is missing a USE dependency default.

All versions of tachyon are unstable and always have been. It will have to be keyworded.

The remaining USE flags are fine to add. But you will occasionally (often) find that some new package needs to be added to package.accept_keywords to get a version that will work with the develop branch of sage.

We also don't have a version of mpmath that works with sage, period, so good luck with that :)

@kiwifb
Copy link
Member

kiwifb commented Aug 22, 2025

For mpmath you'll need at least https://github.com/cschwan/sage-on-gentoo/blob/master/sci-mathematics/sagemath/files/mpmath-10.7.patch and I rm the files that are not used anymore (so as not to bloat the patch). It is high time we start working on that mpmath ticket again.

@kiwifb
Copy link
Member

kiwifb commented Aug 23, 2025

I have taken over the PR for mpmath at #40669

@tobiasdiez
Copy link
Contributor Author

Thanks. The installation of the dependencies is now working (although it takes 4h on CI, is this normal?).

But it now errors out during the cypari2 installation with

error: [Errno 2] No such file or directory: 'gphelp'
      hint: This usually indicates a problem with the package or the build
      environment.

(refs sagemath/cypari2#184)

@kiwifb
Copy link
Member

kiwifb commented Aug 23, 2025

That's because pari has been built without its documentation. The documentation is used in the generation of binding in cypari2 - which would not matter if you had your way sagemath/cypari2#184.
You should get sane gentoo useflags https://github.com/cschwan/sage-on-gentoo/blob/master/tools/package.use/sage the README of the overlay contains instructions on how to use the file.
4hours to build the dependencies on a CI, that doesn't sound bad actually, you probably only have a couple of cpus at most.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants