Packaging SageMath Downstream¶
This document is intended for downstream maintainers (e.g., Linux distribution package maintainers) who wish to create redistributable builds of Sage.
Dependencies¶
SageMath relies on a broad set of Python and system libraries. These must be provided by the downstream distribution. The definitive list of dependencies is found in pyproject.toml.
- These include:
: Python packages needed for building SageMath, : Python packages required at runtime, : optional dependencies for additionalfunctionality,
and : system dependenciesneeded for building,
: system libraries required at runtime.
The
Build Procedure¶
Obtain the Source: Clone the SageMath repository:
git clone https://github.com/sagemath/sage.git Alternatively, download the sdist tarball from the `SageMath PyPI project<https://pypi.org/project/sagemath/>`_ or from the `GitHub releases <https://github.com/sagemath/sage/releases>`_.
Prepare the Build Environment: Ensure a clean and consistent build environment with access to all required system libraries and Python packages.
Build:
Create a wheel using the
module:python -m build --wheel --no-isolation If you are sure that all dependencies are available, you may also add the `--skip-dependency-check` option. Moreover, if you care about reproducible builds, it is recommended to use `-Cbuild-dir=build` to specify a build directory, see this `Meson-Python issue <https://github.com/mesonbuild/meson-python/issues/671>`_.
Install:
The resulting wheel can be installed using
python -m installer --destdir="<pkgdir>" dist/sagemath-*.whl
where
is the directory where you want to install the package (usually a temporary directory for packaging).Test the Build:
Run the Sage tests to ensure functionality:
python -m sage.doctest --all
However, some tests are known to fail, see Issue #39872.
If you maintain a downstream package and encounter build issues or patches that may benefit others, please consider contributing back by reporting issues or opening pull requests on the SageMath GitHub repository.
Other considerations:
- Package naming: Use