|
| 1 | +============================= |
| 2 | +Packaging SageMath Downstream |
| 3 | +============================= |
| 4 | + |
| 5 | +This document is intended for downstream maintainers (e.g., Linux distribution |
| 6 | +package maintainers) who wish to create redistributable builds of Sage. |
| 7 | + |
| 8 | +.. contents:: |
| 9 | + :local: |
| 10 | + :depth: 2 |
| 11 | + |
| 12 | +Dependencies |
| 13 | +============ |
| 14 | + |
| 15 | +SageMath relies on a broad set of Python and system libraries. These must be |
| 16 | +provided by the downstream distribution. The definitive list of dependencies is |
| 17 | +found in `pyproject.toml <https://github.com/sagemath/sage/blob/develop/pyproject.toml>`_. |
| 18 | + |
| 19 | +These include: |
| 20 | + - `build-system.requires`: Python packages needed for building SageMath, |
| 21 | + - `project.dependencies`: Python packages required at runtime, |
| 22 | + - `project.optional-dependencies`: optional dependencies for additional |
| 23 | + functionality, |
| 24 | + - `external.build-requires` and `external.host-requires`: system dependencies |
| 25 | + needed for building, |
| 26 | + - `external.dependencies`: system libraries required at runtime. |
| 27 | + |
| 28 | +The `external` section follows `PEP 725 <https://peps.python.org/pep-0725/>`_ |
| 29 | +and specifies dependencies in the form of ̀PURLs. |
| 30 | +At the moment, there is no standard interface to translate these PURLs into |
| 31 | +system package names. However, the names should be quite self-explanatory. |
| 32 | +You may also consult the section :ref:`spkg` for a list of Sage's |
| 33 | +dependencies and their corresponding system package names in various |
| 34 | +distributions. |
| 35 | + |
| 36 | +Build Procedure |
| 37 | +=============== |
| 38 | + |
| 39 | +1. **Obtain the Source**: |
| 40 | + Clone the SageMath repository: |
| 41 | + |
| 42 | + .. code-block:: bash |
| 43 | +
|
| 44 | + git clone https://github.com/sagemath/sage.git |
| 45 | +
|
| 46 | + Alternatively, download the sdist tarball from the |
| 47 | + `SageMath PyPI project<https://pypi.org/project/sagemath/>`_ or from the |
| 48 | + `GitHub releases <https://github.com/sagemath/sage/releases>`_. |
| 49 | +
|
| 50 | +1. **Prepare the Build Environment**: |
| 51 | + Ensure a clean and consistent build environment with access to all |
| 52 | + required system libraries and Python packages. |
| 53 | + |
| 54 | +2. **Build**: |
| 55 | + |
| 56 | + Create a wheel using the `build` module: |
| 57 | + |
| 58 | + .. code-block:: bash |
| 59 | +
|
| 60 | + python -m build --wheel --no-isolation |
| 61 | +
|
| 62 | + If you are sure that all dependencies are available, you may also add the |
| 63 | + `--skip-dependency-check` option. |
| 64 | + Moreover, if you care about reproducible builds, it is recommended to |
| 65 | + use `-Cbuild-dir=build` to specify a build directory, see this |
| 66 | + `Meson-Python issue <https://github.com/mesonbuild/meson-python/issues/671>`_. |
| 67 | +
|
| 68 | +3. **Install**: |
| 69 | +
|
| 70 | + The resulting wheel can be installed using |
| 71 | +
|
| 72 | + .. code-block:: bash |
| 73 | +
|
| 74 | + python -m installer --destdir="<pkgdir>" dist/sagemath-*.whl |
| 75 | +
|
| 76 | + where `<pkgdir>` is the directory where you want to install the package |
| 77 | + (usually a temporary directory for packaging). |
| 78 | +
|
| 79 | +4. **Test the Build**: |
| 80 | +
|
| 81 | + Run the Sage tests to ensure functionality: |
| 82 | +
|
| 83 | + .. code-block:: bash |
| 84 | +
|
| 85 | + python -m sage.doctest --all |
| 86 | +
|
| 87 | + However, some tests are known to fail, see :issue:`39872`. |
| 88 | +
|
| 89 | +
|
| 90 | +If you maintain a downstream package and encounter build issues or patches |
| 91 | +that may benefit others, please consider contributing back by reporting issues |
| 92 | +or opening pull requests on the SageMath GitHub repository. |
| 93 | +
|
| 94 | +Other considerations: |
| 95 | +- **Package naming**: Use `sagemath`, or `python-sagemath` if your distribution |
| 96 | +has a convention for Python packages. |
| 97 | +
|
| 98 | +Example Downstream Packages |
| 99 | +=========================== |
| 100 | +
|
| 101 | +- `Arch Linux <https://archlinux.org/packages/extra/x86_64/sagemath>`_ |
| 102 | +
|
0 commit comments