After the decade-long diversion preventing the sage library from
having a real build system, we can finally pass options to meson
to enable or disable features, such as -Dmeataxe=disabled.
We also have our feature system that attempts to detect all of these
things at runtime, repeatedly:
$ sage -t example.py
Running doctests with ID 2026-05-10-08-13-30-6cdf578c.
Running with SAGE_LOCAL='/usr'
Using --optional=sage
Features to be detected: 32_bit,4ti2,benzene,bliss,buckygen,
conway_polynomials,coxeter3,csdp,cvxopt,cvxopt,
database_cremona_ellcurve,database_cremona_mini_ellcurve,
database_cubic_hecke,database_ellcurves,database_graphs,
...
This is ugly (I'm slowly working on that), but more to the point, is
often a waste of time. If I disable meataxe when I build sage, it's a
waste of resources to repeatedly check for it, because it's just not
going to be there. And if by some miracle Sage does determine that
meataxe is available... I still don't want to run the tests for it,
because I disabled it, and presumably had a good reason to do so.
After a lot of thought and discussion, we came up with a plan for
this:
*
https://github.com/sagemath/sage/discussions/41067
Option 3 is now implemented at,
*
https://github.com/sagemath/sage/pull/41550
It's a relatively safe change at this point. We introduce a new
BuildFeature class, and a meson option called defer_feature_checks.
The existing features (such as meataxe) are made a BuildFeature, and
the value of -Dmeataxe=enabled is recorded at build time. The feature
test then just returns the recorded value, i.e. does not poke around
on the system. For backwards compatibility, defer_feature_checks=True
retains the old behavior, and is the default in the Sage distribution.
The PR is mostly boilerplate conversion of the feature classes for the
existing options in the meson.options file. After the conversion,
build-time features no longer appear in the
Features to be detected: 32_bit,4ti2,...
list, so it will slowly get less ugly if you opt in. And for people
packaging sage, it becomes a lot easier to know what its dependencies
are, and to avoid surprise test failures when a user installs an
optional package whose tests have bit-rotted.