<div id="comment:0"></div> cherry-picked from #32432. We also fix up `sage.features.sagemath`. CC: @kliem Component: **refactoring** Author: **Matthias Koeppe** Branch: **[`b846c0a`](https://github.com/sagemath/sagetrac-mirror/commit/b846c0a9e1b36a99bd714630553808d18204dba4)** Reviewer: **Dima Pasechnik** _Issue created by migration from https://trac.sagemath.org/ticket/32732_