Skip to content

Commit eba252a

Browse files
committed
Add documentation for packaging SageMath downstream
1 parent d617df4 commit eba252a

File tree

3 files changed

+101
-1
lines changed

3 files changed

+101
-1
lines changed

src/doc/en/developer/downstream.rst

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
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+
python3 -m installer dist/sagemath-*.whl
75+
76+
4. **Test the Build**:
77+
78+
Run the Sage tests to ensure functionality:
79+
80+
.. code-block:: bash
81+
82+
python -m sage.doctest --all
83+
84+
However, some tests are known to fail, see :issue:`39872`.
85+
86+
87+
If you maintain a downstream package and encounter build issues or patches
88+
that may benefit others, please consider contributing back by reporting issues
89+
or opening pull requests on the SageMath GitHub repository.
90+
91+
Other considerations:
92+
- **Package naming**: Use `sagemath`, or `python-sagemath` if your distribution
93+
has a convention for Python packages.
94+
95+
Example Downstream Packages
96+
===========================
97+
98+
- `Arch Linux <https://aur.archlinux.org/packages/sagemath-git>`_
99+

src/doc/en/developer/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ Packaging
174174
:maxdepth: 2
175175

176176
packaging
177+
downstream
177178
packaging_sage_library
178179

179180

src/doc/en/developer/packaging_sage_library.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
.. _chapter-modularization:
33

44
===========================================
5-
Packaging the Sage Library for Distribution
5+
Modularized Distribution
66
===========================================
77

88

0 commit comments

Comments
 (0)