Skip to content

Commit 7dc3a24

Browse files
author
Release Manager
committed
gh-40162: Add documentation for packaging SageMath downstream <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes #12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes #12345". --> Using meson. Should hopefully make it easier for downstream maintainers to get started, so that we might get sage back in Fedora/Ubuntu/... I don't have any packaging experience myself, so please make suggestions! ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [ ] The title is concise and informative. - [ ] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - #12345: short description why this is a dependency --> <!-- - #34567: ... --> URL: #40162 Reported by: Tobias Diez Reviewer(s): Antonio Rojas, Copilot, Dima Pasechnik, Tobias Diez
2 parents dcadc84 + 7fac784 commit 7dc3a24

File tree

4 files changed

+107
-1
lines changed

4 files changed

+107
-1
lines changed

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,15 @@
8181
"pari",
8282
"prandom",
8383
"Pynac",
84+
"pyproject",
8485
"rightarrow",
8586
"sagemath",
8687
"scalarfield",
88+
"sdist",
8789
"SEEALSO",
8890
"setminus",
8991
"smithform",
92+
"spkg",
9093
"subchart",
9194
"subcharts",
9295
"subframe",

src/doc/en/developer/downstream.rst

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
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+

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)