Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile everything with meson #36524

Open
wants to merge 212 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
212 commits
Select commit Hold shift + click to select a range
bfac057
Use meson instead of configure for conda install
tobiasdiez Oct 20, 2023
9694046
remove editable wheel customization
tobiasdiez Oct 20, 2023
376742a
remove configure from conda ci
tobiasdiez Oct 20, 2023
e270392
Merge remote-tracking branch 'tobiasdiez/ci-conda-error' into meson-c…
tobiasdiez Oct 20, 2023
a21655b
Merge remote-tracking branch 'mkoeppe/conda_legacy_editable' into mes…
tobiasdiez Oct 20, 2023
84ff7ff
Revert "remove editable wheel customization"
tobiasdiez Oct 20, 2023
885e2b4
split setup and conf for cleaner display
tobiasdiez Oct 20, 2023
f755a8e
add meson to conda env
tobiasdiez Oct 20, 2023
4406868
Fix style in conda docs
tobiasdiez Oct 21, 2023
c0cdb5f
add meson only in src env files
tobiasdiez Oct 21, 2023
b408311
keep configure around in the ci
tobiasdiez Oct 21, 2023
4c8b56b
Merge remote-tracking branch 'origin/develop' into meson-config
tobiasdiez Oct 21, 2023
f6f27d9
fix conda-ci
tobiasdiez Oct 21, 2023
b4ff544
Compile categories with meson
tobiasdiez Oct 24, 2023
26cca82
Restore atexit
tobiasdiez Oct 24, 2023
b2e7046
improve installation using meson-python
tobiasdiez Oct 24, 2023
090aa2a
small improvements
tobiasdiez Oct 25, 2023
393aa08
add a few more meson build files
tobiasdiez Oct 28, 2023
7c2f3a1
add more meson files
tobiasdiez Oct 29, 2023
a1dc936
readd init
tobiasdiez Oct 29, 2023
8a2cc9c
Fix build (kind of)
tobiasdiez Oct 30, 2023
9baf964
Add meson to ci
tobiasdiez Oct 30, 2023
21c4c9a
improve ci
tobiasdiez Oct 30, 2023
c3cdc31
don't apply ci fixes
tobiasdiez Oct 30, 2023
52bc4c6
add pytest to conda env
tobiasdiez Oct 30, 2023
8427fae
Merge remote-tracking branch 'tobiasdiez/rel_import_small' into meson…
tobiasdiez Oct 30, 2023
a06732f
Merge remote-tracking branch 'tobiasdiez/rel_import_structure' into m…
tobiasdiez Oct 30, 2023
10bfec3
Merge remote-tracking branch 'tobiasdiez/rel_import_categories' into …
tobiasdiez Oct 30, 2023
2c4f316
Merge remote-tracking branch 'tobiasdiez/rel_import_rings' into meson…
tobiasdiez Oct 30, 2023
c52827e
improve generate meson script
tobiasdiez Oct 30, 2023
677c1f1
use sage to run pytest in ci
tobiasdiez Oct 30, 2023
fdd1655
add more meson configs
tobiasdiez Oct 30, 2023
3840207
Merge remote-tracking branch 'tobiasdiez/rel_import_rings' into meson…
tobiasdiez Oct 30, 2023
781f001
Merge branch 'rel_import_modules' into meson-compile
tobiasdiez Oct 30, 2023
0152168
Merge branch 'rel_headers' into meson-compile
tobiasdiez Oct 30, 2023
119fcfa
add version to pyproject.toml
tobiasdiez Oct 31, 2023
0760fb2
fix test command in ci
tobiasdiez Oct 31, 2023
573b569
Merge remote-tracking branch 'origin/develop' into meson-compile
tobiasdiez Oct 31, 2023
f25cbfa
add more meson build files
tobiasdiez Oct 31, 2023
eaa267f
Merge remote-tracking branch 'tobiasdiez/rel_import_rings' into meson…
tobiasdiez Oct 31, 2023
5930aff
More meson files
tobiasdiez Oct 31, 2023
e650614
Merge branch 'rel_import_ntl' into meson-compile
tobiasdiez Oct 31, 2023
100a35d
Add interpreters
tobiasdiez Nov 2, 2023
5e28f54
Merge branch 'interpreters_outdir' into meson-compile
tobiasdiez Nov 2, 2023
72799e7
Merge remote-tracking branch 'tobiasdiez/rel_headers' into meson-compile
tobiasdiez Nov 2, 2023
f0acc6d
Merge remote-tracking branch 'mkoeppe/absolute_cimport_sage_graphs' i…
tobiasdiez Nov 2, 2023
dbe7b15
Merge remote-tracking branch 'mkoeppe/absolute_cimport_sage_libs' int…
tobiasdiez Nov 2, 2023
111b145
And another round of meson files
tobiasdiez Nov 2, 2023
c279072
Fix matrix
tobiasdiez Nov 2, 2023
a993e90
Merge remote-tracking branch 'mkoeppe/absolute_cimport_sage_geometry'…
tobiasdiez Nov 2, 2023
8accfbd
Last set of meson files
tobiasdiez Nov 2, 2023
9db105f
Last set of relative imports
tobiasdiez Nov 2, 2023
d3aaee7
cleanup
tobiasdiez Nov 3, 2023
2486d99
fix ci
tobiasdiez Nov 3, 2023
3e5f3c1
Improve symbolic compilation
tobiasdiez Nov 4, 2023
3990cc0
improve docs
tobiasdiez Nov 9, 2023
d8c04cf
git ignore old so files
tobiasdiez Nov 9, 2023
c27aa7b
use dependency to find singular
tobiasdiez Nov 9, 2023
f0cbcfe
remove outdated comment
tobiasdiez Nov 11, 2023
e70b24e
remove gmpxx in symbolic
tobiasdiez Nov 11, 2023
4519e18
fix a few runtime errors
tobiasdiez Nov 11, 2023
f5cc9d6
Merge remote-tracking branch 'tobiasdiez/rel_import_modules' into pr/…
tobiasdiez Nov 12, 2023
e4afb29
Properly compile dynamics
tobiasdiez Nov 12, 2023
c0e6c59
properly compile sat
tobiasdiez Nov 12, 2023
eaa04d4
ci: run tests
tobiasdiez Nov 12, 2023
44d7498
Fix a few runtime errors
tobiasdiez Nov 14, 2023
9d5afd3
Add missing singular dependencies
tobiasdiez Nov 14, 2023
dec2e02
Drop bogus ginac depencency
tobiasdiez Nov 14, 2023
310975e
Fix a few more runtime errors
tobiasdiez Nov 14, 2023
1c1bfa3
Remove dependency on https://github.com/sagemath/sage/pull/36489
tobiasdiez Nov 14, 2023
7727ab1
fix farey compilation
tobiasdiez Nov 14, 2023
8a6d93b
remove duplicate dependency
tobiasdiez Nov 14, 2023
d700f64
Fix farey compilation
tobiasdiez Nov 14, 2023
c60c866
Remove obsolete uncommented code
tobiasdiez Nov 14, 2023
edcdb2a
Try to fix farey header compilation
tobiasdiez Nov 14, 2023
93d9000
try to fix farey compilation in ci
tobiasdiez Nov 14, 2023
903c79b
Another try to fix farey
tobiasdiez Nov 14, 2023
cdc880f
Merge remote-tracking branch 'origin/develop' into pr/tobiasdiez/36524
tobiasdiez Nov 14, 2023
9d689cb
Don't install farey header
tobiasdiez Nov 14, 2023
37a67ab
Fix farey import error
tobiasdiez Nov 14, 2023
3cee517
Merge branch 'develop' into meson-compile
tobiasdiez Nov 15, 2023
395c310
Remove old warning about sage.gaprc
tobiasdiez Nov 16, 2023
b63beef
Fix compilation of interpreters
tobiasdiez Nov 16, 2023
49fa87b
Git-ignore all builddirs
tobiasdiez Nov 16, 2023
82c5f2b
Include static maxima file
tobiasdiez Nov 16, 2023
8453c1c
Readd a few all imports
tobiasdiez Nov 16, 2023
97053a7
Recreate missing init files
tobiasdiez Nov 16, 2023
efe272c
create dependency on generated interpreters
tobiasdiez Nov 16, 2023
17888c9
Readd interpreter generation in ci
tobiasdiez Nov 16, 2023
946ef70
And remove some of the init files again
tobiasdiez Nov 16, 2023
0189df5
Fix interpreters include directory
tobiasdiez Nov 16, 2023
ef0ba56
Fix glpk import error
tobiasdiez Nov 16, 2023
56e1d8d
Fix arb runtime error
tobiasdiez Nov 16, 2023
1199bcd
Add missing init file
tobiasdiez Nov 18, 2023
5759c28
Fix runtime errors due to missing glpk
tobiasdiez Nov 18, 2023
b4988ff
Don't remove init file in interpreters
tobiasdiez Nov 18, 2023
bd9fd26
Fix missing pari dependency
tobiasdiez Nov 19, 2023
592e2f4
cleanup ci
tobiasdiez Nov 19, 2023
4f5b91b
install ext_data
tobiasdiez Nov 19, 2023
7a5c83e
Don't fail fast in ci
tobiasdiez Nov 19, 2023
c00b92f
set env variables correctly
tobiasdiez Nov 19, 2023
b391063
Add a few missing headers
tobiasdiez Nov 19, 2023
b78557d
correctly specify version
tobiasdiez Nov 20, 2023
353b989
Properly set SAGE_SHARE to datadir, and warn if cremona is not installed
tobiasdiez Nov 20, 2023
46dbc4f
Install more headers
tobiasdiez Nov 20, 2023
d328913
Readd init files
tobiasdiez Nov 24, 2023
817c49c
Fix tests
tobiasdiez Nov 24, 2023
b5ffbe6
Fix linter
tobiasdiez Nov 24, 2023
fef4acf
Merge branch 'develop' into init_files
tobiasdiez Dec 6, 2023
41a9f0e
Merge branch 'develop' into meson-compile
tobiasdiez Dec 7, 2023
f001d1a
Merge remote-tracking branch 'upstream/develop' into meson-compile
tobiasdiez Dec 7, 2023
db94088
Merge branch 'meson-compile' of https://github.com/tobiasdiez/sage in…
tobiasdiez Dec 7, 2023
4698e07
update meson files
tobiasdiez Dec 7, 2023
1adecdb
fix bernmm compilation
tobiasdiez Dec 7, 2023
56f3394
fix missing python file
tobiasdiez Dec 7, 2023
c9f9948
fix a few more failing tests by installing necessary files
tobiasdiez Dec 8, 2023
7205317
embed file position into cython docstrings
tobiasdiez Dec 9, 2023
4e5d73e
Merge remote-tracking branch 'tobiasdiez/init_files' into meson-compile
tobiasdiez Dec 9, 2023
7851141
Merge branch 'develop' into init_files
tobiasdiez Dec 10, 2023
e39f031
Merge branch 'develop' into meson-compile
tobiasdiez Dec 10, 2023
f74c257
Merge remote-tracking branch 'origin/develop' into pr/tobiasdiez/36524
tobiasdiez Dec 14, 2023
36a8e75
Fix build error
tobiasdiez Dec 14, 2023
b468af3
cleanup
tobiasdiez Dec 14, 2023
95ed032
Remove explicit file names from docs
tobiasdiez Dec 14, 2023
4280f5d
Merge remote-tracking branch 'upstream/develop' into meson-compile
tobiasdiez Dec 19, 2023
d19ce80
Update meson file of sets
tobiasdiez Dec 19, 2023
192c26b
Revert "Remove old warning about sage.gaprc"
tobiasdiez Dec 19, 2023
88b6edd
fix farey header import
tobiasdiez Dec 19, 2023
cea7fd7
Print more infos during ci
tobiasdiez Dec 19, 2023
d2440c7
Implement gap root discovery in meson
tobiasdiez Dec 19, 2023
88b8b47
Install missing directory
tobiasdiez Dec 19, 2023
9879646
fix failing test
tobiasdiez Dec 19, 2023
2e44f4f
docs: uninstall other sage packages
tobiasdiez Dec 19, 2023
6a5a8da
include missing cython source file
tobiasdiez Dec 19, 2023
1ab5f9e
Install missing file in groups
tobiasdiez Dec 19, 2023
2fe2862
Merge remote-tracking branch 'upstream/develop' into init_files
tobiasdiez Dec 19, 2023
580e14d
Merge branch 'develop' into meson-compile
tobiasdiez Dec 27, 2023
76dfa79
Merge branch 'develop' into init_files
tobiasdiez Dec 27, 2023
7891c11
Remove unused setuptools versioning in pyproject.toml
tobiasdiez Dec 30, 2023
ff68103
Fix bug with Cython source code not appearing in tracebacks
tobiasdiez Dec 30, 2023
8793852
Fix runtime problem with lie algebras
tobiasdiez Dec 30, 2023
f930634
Cleanup meson files
tobiasdiez Dec 30, 2023
866000e
Update documentation
tobiasdiez Dec 30, 2023
dbef9cc
Add meson as an installation option in table of contents
tobiasdiez Dec 30, 2023
1174548
Use ccache action
tobiasdiez Dec 30, 2023
52f0032
Add ccache to project compilers as workaround
tobiasdiez Dec 30, 2023
76c36e3
Remove ccache from conda env
tobiasdiez Dec 30, 2023
ad1b8a7
Update ccache-action to use main branch
tobiasdiez Dec 30, 2023
482dd0d
Explicitly set path to ccache
tobiasdiez Dec 30, 2023
7943da6
Fix ccache-action version
tobiasdiez Dec 30, 2023
e8ae9cf
Update build configuration to force use ccache
tobiasdiez Dec 30, 2023
634512b
Fix reference to section-prereqs in meson.rst
tobiasdiez Dec 31, 2023
1c47bcd
Fix broken link in installation instructions
tobiasdiez Dec 31, 2023
46bc6b4
Fix ccache restore key
tobiasdiez Dec 31, 2023
d823087
Merge branch 'develop' into init_files
tobiasdiez Jan 15, 2024
b4bcaf1
Merge branch 'develop' into meson-compile
tobiasdiez Jan 15, 2024
37e9d49
Update flint meson file
tobiasdiez Jan 16, 2024
4ef94d4
Update test command to use 4 parallel processes
tobiasdiez Jan 16, 2024
0a4c97d
Merge branch 'develop' into meson-compile
tobiasdiez Jan 22, 2024
7ceba8a
Merge branch 'develop' into init_files
tobiasdiez Jan 28, 2024
ae4571d
Merge branch 'develop' into init_files
tobiasdiez Feb 11, 2024
2d0cbe7
Merge branch 'develop' into meson-compile
tobiasdiez Feb 11, 2024
30c7049
Remove gap_packages.py from py.install_sources()
tobiasdiez Feb 11, 2024
0d8b2d7
Add new Python files to various modules
tobiasdiez Feb 11, 2024
dc24eaf
Add order_ideal.py to number_field module
tobiasdiez Feb 13, 2024
dacc419
Delete unused meson files in algebras and combinatorics
tobiasdiez Feb 13, 2024
be36e74
Merge remote-tracking branch 'upstream/develop' into meson-compile
tobiasdiez Feb 15, 2024
6a89c45
Add new files to categories and designs
tobiasdiez Feb 15, 2024
6b14ccb
Remove unnecessary meson_version field from project configuration
tobiasdiez Feb 18, 2024
087df3f
Update install_sources in meson files
tobiasdiez Feb 18, 2024
e866cbc
update cython files
tobiasdiez Feb 19, 2024
bf0c7f7
Refactor matrix build dependencies and add meataxe dependency for mat…
tobiasdiez Feb 19, 2024
911e714
Merge branch 'develop' into init_files
tobiasdiez Feb 19, 2024
57b8a9e
Try to fix doctest on macos
tobiasdiez Feb 22, 2024
b578c77
Update library dependencies handling in meson.build files
tobiasdiez Feb 22, 2024
d2c8520
Revert "Try to fix doctest on macos"
tobiasdiez Feb 23, 2024
f538e1a
Fix exponent overflow bug in RingElement class
tobiasdiez Feb 23, 2024
71396c2
Improve handling of dependencies
tobiasdiez Feb 23, 2024
c4f21dd
Merge branch 'develop' into init_files
tobiasdiez Feb 25, 2024
bae9fb0
Merge branch 'develop' into meson-compile
tobiasdiez Feb 25, 2024
e509b11
Add script for updating Python sources and extension data in meson bu…
tobiasdiez Feb 27, 2024
62bf19f
Remove unnecessary code for finding include path for Cython modules
tobiasdiez Feb 27, 2024
5e7a899
Improve code for generating interpreters
tobiasdiez Feb 27, 2024
d129c03
Update CI workflow to use lock environment file
tobiasdiez Feb 27, 2024
434225c
Remove unnecessary arb include directory in meson.build files
tobiasdiez Feb 27, 2024
3fbe6a3
add meson to conda lock file
tobiasdiez Feb 28, 2024
8d1acf8
Remove unnecessary interpreters include_directories in meson.build files
tobiasdiez Feb 28, 2024
b26b887
Merge branch 'pr/antonio-rojas/37484' into meson-compile
tobiasdiez Feb 28, 2024
e435308
Fix compilation (arb)
tobiasdiez Feb 28, 2024
c83cc2f
try to fix interpreter build
tobiasdiez Feb 28, 2024
a1e41c1
More fun with interpreters
tobiasdiez Feb 28, 2024
0d5f088
Add build directory as include directory for Cython compilation
tobiasdiez Feb 28, 2024
0913750
Merge branch 'develop' into meson-compile
tobiasdiez Mar 5, 2024
765c5b9
Don't run pytest on builddir
tobiasdiez Mar 10, 2024
159d350
Restore --config-settings editable_mode=compat in ci-conda
tobiasdiez Mar 10, 2024
e036436
Cleanup workflow
tobiasdiez Mar 10, 2024
020cb40
Merge remote-tracking branch 'upstream/develop' into init_files
tobiasdiez Mar 10, 2024
0b2d76f
Ignore module-not-measured error during code coverage collection
tobiasdiez Mar 10, 2024
8c21bc5
Remove acidentially commited submodules
tobiasdiez Mar 10, 2024
16d8234
Move compilers to src/meson.build
tobiasdiez Mar 10, 2024
11cb41c
Remove acidentially commited submodules
tobiasdiez Mar 10, 2024
c8e3a18
Merge branch 'init_files' into meson-compile
tobiasdiez Mar 10, 2024
861506a
Fix tests
tobiasdiez Mar 10, 2024
5d62950
Try installing the generated init file to fix cython module name issues
tobiasdiez Mar 10, 2024
757932f
Generate init file for interpreters
tobiasdiez Mar 10, 2024
73c840a
Improve fflas dependency in meson.build
tobiasdiez Mar 10, 2024
3819a6e
Add fallback for gap
tobiasdiez Mar 10, 2024
ee096c9
Add more fallback subprojects
tobiasdiez Mar 10, 2024
614ad77
Merge branch 'develop' into meson-compile
dimpase Mar 25, 2024
a048c2a
Merge branch 'develop' into meson-compile
dimpase Apr 4, 2024
cf571d2
Merge branch 'develop' into meson-compile
tobiasdiez Apr 28, 2024
49dc635
Merge branch 'develop' into meson-compile
dimpase Jun 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
76 changes: 76 additions & 0 deletions .github/workflows/ci-meson.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Build & Test using Meson

on:
push:
branches:
- master
- develop
pull_request:
workflow_dispatch:
# Allow to run manually

concurrency:
# Cancel previous runs of this workflow for the same branch
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
name: Conda (${{ matrix.os }}, Python ${{ matrix.python }})
runs-on: ${{ matrix.os }}-latest

strategy:
fail-fast: false
matrix:
os: [ubuntu, macos]
python: ['3.9', '3.10', '3.11']

steps:
- uses: actions/checkout@v4

- name: Merge CI fixes from sagemath/sage
run: |
.ci/merge-fixes.sh
env:
GH_TOKEN: ${{ github.token }}

- name: Cache conda packages
uses: actions/cache@v3
with:
path: ~/conda_pkgs_dir
key:
${{ runner.os }}-conda-${{ hashFiles('src/environment-3.11-linux.yml') }}

- name: Compiler cache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ${{ runner.os }}-meson-${{ matrix.python }}

- name: Setup Conda environment
uses: conda-incubator/setup-miniconda@v2
with:
python-version: ${{ matrix.python }}
miniforge-version: latest
use-mamba: true
channels: conda-forge
channel-priority: true
activate-environment: sage
environment-file: src/environment-${{ matrix.python }}-${{ startsWith(matrix.os, 'macos') && 'macos' || 'linux' }}.yml

- name: Print Conda environment
shell: bash -l {0}
run: |
conda info
conda list

- name: Build
shell: bash -l {0}
run: |
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
export CC="ccache $CC"
export CXX="ccache $CXX"
pip install --no-build-isolation --config-settings=builddir=builddir . -v

- name: Test
shell: bash -l {0}
run: ./sage -t --all -p4
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ __pycache__/
# Generated Cython files
*.so
**/*.so
**/*.so.old
/src/cython_debug
# Most C and C++ files are generated by Cython and should not
# be included in the sdist.
Expand Down Expand Up @@ -298,3 +299,7 @@ src/.coverage/
# git worktree
worktree*
**/worktree*

# meson build directory
builddir
builddir-*
3 changes: 3 additions & 0 deletions bootstrap-conda
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ echo >&2 $0:$LINENO: generate conda environment files
) > environment-template.yml
(
sed 's/name: sage-build/name: sage/' environment-template.yml
echo " - meson"
echo " - meson-python"
echo " - pytest"
echo " # Additional packages providing all dependencies for the Sage library"
for pkg in $SAGELIB_SYSTEM_PACKAGES; do
echo " - $pkg"
Expand Down
32 changes: 32 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
project(
'SageMath',
['c', 'cpp', 'cython'],
version: files('src/VERSION.txt'),
license: 'GPL v3'
)

# Python module
# https://mesonbuild.com/Python-module.html
py_module = import('python')
py = py_module.find_installation(pure: false)
py_dep = py.dependency()

# Additional targets
py_with_pytest = py_module.find_installation(required: false, modules: ['pytest'])
if py_with_pytest.found()
test(
'pytest',
py_with_pytest,
args: [
'-m',
'pytest',
'-c',
meson.current_source_dir() / 'tox.ini',
'--doctest',
meson.current_source_dir() / 'src' / 'sage' / 'categories'
],
timeout: 0,
)
endif

subdir('src')
1 change: 1 addition & 0 deletions pkgs/sage-conf/_sage_conf/_conf.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ VERSION = "@PACKAGE_VERSION@"
# to it.
SAGE_LOCAL = "@prefix@"
SAGE_ROOT = "@SAGE_ROOT@"
SAGE_SHARE = "@SAGE_SHARE@"

# The semicolon-separated list of GAP root paths. This is the list of
# locations that are searched for GAP packages. This is passed directly
Expand Down
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[build-system]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I have said before in #36489 (comment), I disagree with making this structural change of making SAGE_ROOT the root of a Python project by introducing the file pyproject.toml.

In #36503 (comment) you denied that you're even making this structural change, but here on the PR it is now fully formed, by declaring a new Python project ("sagemath").

I have made the reason for my objection clear before: Both this file (and the introduction of the file meson.build in SAGE_ROOT, as discussed in #36489 (comment)) mislead users into assuming that they can build Sage using pip install . and/or meson ... instead of using ./configure && make. This is not true because the latter are the build system of the Sage distribution, whereas you have developed a build system for the (monolithic) Sage library -- with is the Python project already declared in src/pyproject.toml named "sagemath-standard".

The correct solution is to edit src/pyproject.toml so that the Sage library uses the mesonpy build system instead of setuptools (delete setup.py), and to use src/meson.build as the toplevel meson file. This affects the default (monolithic editable) build. Users can use ./configure --disable-editable or ./configure --disable-editable --enable-wheels to switch back to a setuptools-based build system.

As I explained in #36489 (comment), changing the structure of SAGE_ROOT in this PR is simply not necessary for the goal of the PR -- building the Sage library with meson, which makes the bundling inappropriate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have made the reason for my objection clear before: Both this file (and the introduction of the file meson.build in SAGE_ROOT, as discussed in #36489 (comment)) mislead users into assuming that they can build Sage using pip install . and/or meson ... instead of using ./configure && make. This is not true because the latter are the build system of the Sage distribution, whereas you have developed a build system for the (monolithic) Sage library -- with is the Python project already declared in src/pyproject.toml named "sagemath-standard".

I've developed an alternative for make for the sage project. In this meson alternative, there is not such a distinction between sage-the-distribution and sage-library. There is one project, called sage (or sagemath if you prefer). You can build it using pip install . (plus some args) or using meson compile (plus some args) from the root. The only difference to the current make build command is that the developer is responsible for setting up the surrounding build environment (i.e. if dependencies are not present, the build fails). This is very much similar to scipy/numpy/name another meson project.

The correct solution is to edit src/pyproject.toml so that the Sage library uses the mesonpy build system instead of setuptools (delete setup.py), and to use src/meson.build as the toplevel meson file. This affects the default (monolithic editable) build. Users can use ./configure --disable-editable or ./configure --disable-editable --enable-wheels to switch back to a setuptools-based build system.

I don't think the meson-based system can directly function as a new default. It's unrealistic that it will directly as stable as the existing setuptools-based one. So it should be opt-in instead of opt-out. So the root directory is the only option I see to place the new pyprojecttoml file.

Copy link
Member

@mkoeppe mkoeppe Nov 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've developed an alternative for make for the sage project. In this meson alternative, there is not such a distinction between sage-the-distribution and sage-library.

Try to explain how what you are doing is different from building the Sage library.

(Edit: Previously asked but not answered in the thread starting at #36489 (comment))

Copy link
Member

@mkoeppe mkoeppe Nov 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only difference to the current make build command is that the developer is responsible for setting up the surrounding build environmen

Does this not mean that it is doing nothing of what the Sage distribution does in addition to the Sage library?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[...] So the root directory is the only option I see to place the new pyprojecttoml file.

Happy to help:

  • Option 1: An environment variable could switch src/pyproject.toml from using setuptools to using mesonpy. Trivial to do by declaring a custom PEP-517/660 build api (about 10 lines of code); reference: sage_setup: Add PEP 517 / PEP 660 buildapi #29845
  • Option 2: A directory pkgs/sagemath-standard_meson with pyproject.toml.m4

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've developed an alternative for make for the sage project. In this meson alternative, there is not such a distinction between sage-the-distribution and sage-library.

Try to explain how what you are doing is different from building the Sage library.

Yes of course its building the sage library....that's also the end-goal of sage-the-distribution.

Sage-the-library doesn't have any means to detect and link libraries that are needed for its compilation (except a few runtime fallbacks). Finding and setting these dependencies up is currently the job of sage-the-distribution. This part of sage-the-distribution is covered by meson.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sage-the-library doesn't have any means to detect and link libraries that are needed for its compilation

That's false. It is using pkg-config for this purpose.

build-backend = 'mesonpy'
requires = ['meson-python', 'cython>=3.0.0']

[project]
name = 'sagemath'
dynamic = ["version"]
1 change: 1 addition & 0 deletions src/doc/en/installation/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ More information:
binary
conda
source
meson
launching
troubles

Expand Down
107 changes: 107 additions & 0 deletions src/doc/en/installation/meson.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
.. _build-source-meson:

================================
Building from source using Meson
================================

This is a short guide on how to build the Sage from source using Meson.

Walkthrough
===========

Assume we're starting from a clean repo and a fully set up conda environment::

```bash
./bootstrap-conda
mamba env create --file src/environment-dev-3.11.yml --name sage-dev
conda activate sage-dev
```

Alternatively, install all build requirements as described in section
:ref:`section-prereqs`.

.. NOTE::

If you have previously build Sage in-place, you first have to delete the
already compiled files, e.g. with ``shopt -s globstar`` followed by
``rm src/**/*.so`` or ``for f in src/**/*.so ; do mv "$f" "$f.old"; done``.
Also uninstall the 'old' sage packages with ``pip uninstall sage-conf sage-setup sagemath-standard``.

To compile and install the project in editable install, just use::

```bash
pip install --no-build-isolation --editable .
```

This will install Sage in the current Python environment. You can then start
Sage from the command line with ``./sage`` or run the tests with ``./sage -t``.

.. NOTE::

By using ``pip install --editable`` in the above steps, the Sage library
is installed in editable mode. This means that when you only edit source
files, there is no need to rebuild the library; it suffices to restart Sage.
Note that this even works when you edit Cython files, so you no longer need
to manually compile after editing Cython files.

.. NOTE::

Note that ``make`` is not used at all, nor is ``configure``.
This means that any Sage-the-distribution commands such as ``sage -i``
will not work.

Background information
======================

Under the hood, pip invokes meson to configure and build the project.
We can also use meson directly as follows.

To configure the project, we need to run the following command::

```bash
meson setup builddir --prefix=$PWD/build-install
```

This will create a build directory ``builddir`` that will hold the build artifacts.
The ``--prefix`` option specifies the directory where the Sage will be installed.
To compile the project, run the following command::

```bash
meson compile -C builddir
```

Installing is done with the following command::

```bash
meson install -C builddir
```

This will then install in the directory specified by ``--prefix``, e.g.
`build-install/lib/python3.11/site-packages/sage`.
Usually, this directory is not on your Python path, so you have to use::

```bash
PYTHONPATH=build-install/lib/python3.11/site-packages ./sage
```

Alternatively, we can still use pip to install::

```bash
pip install --no-build-isolation --config-settings=builddir=builddir --editable .
```

.. tip::

Package maintainers may want to specify further build options or need
to install to a different directory than the install prefix.
Both are supported naturally by Meson::

```bash
meson setup builddir --prefix=/usr --libdir=... -Dcpp_args=...
meson compile -C builddir
DESTDIR=/path/to/staging/root meson install -C builddir
```

See `Meson's quick guide <https://mesonbuild.com/Quick-guide.html#using-meson-as-a-distro-packager>`_
and `Meson's install guide <https://mesonbuild.com/Installing.html#destdir-support>`_
for more information.
6 changes: 6 additions & 0 deletions src/doc/en/installation/source.rst
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,12 @@ does not raise an :class:`ImportError`, then it worked.
Installation steps
------------------

.. hint::

The following steps use the classical ``./configure && make`` build
process. The modern Meson build system is also supported, see
:ref:`build-source-meson`.

#. Follow the procedure in the file `README.md <https://github.com/sagemath/sage/#readme>`_
in ``SAGE_ROOT``.

Expand Down
12 changes: 7 additions & 5 deletions src/environment-3.10-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -361,10 +361,11 @@ dependencies:
- libxkbcommon=1.6.0=h5d7e998_0
- matplotlib-inline=0.1.6=pyhd8ed1ab_0
- memory-allocator=0.1.3=py310h2372a71_0
- overrides=7.4.0=pyhd8ed1ab_0
- pexpect=4.8.0=pyh1a96a4e_2
- pillow=10.1.0=py310h01dd4db_0
- pip=23.3.2=pyhd8ed1ab_0
- meson=1.3.2=pyhd8ed1ab_0
- overrides=7.7.0=pyhd8ed1ab_0
- pexpect=4.9.0=pyhd8ed1ab_0
- pillow=10.2.0=py310h01dd4db_0
- pip=24.0=pyhd8ed1ab_0
- pplpy=0.8.9=py310h28f6eb6_0
- primecountpy=0.1.0=py310hd41b1e2_4
- prompt-toolkit=3.0.42=pyha770c72_0
Expand Down Expand Up @@ -400,7 +401,8 @@ dependencies:
- jsonschema-specifications=2023.11.2=pyhd8ed1ab_0
- jupyter_server_terminals=0.5.0=pyhd8ed1ab_0
- liblapacke=3.9.0=20_linux64_openblas
- numpy=1.26.2=py310hb13e2d6_0
- meson-python=0.15.0=pyh0c530f3_0
- numpy=1.26.4=py310hb13e2d6_0
- prompt_toolkit=3.0.42=hd8ed1ab_0
- pyqt5-sip=12.12.2=py310hc6cd4ac_5
- requests=2.31.0=pyhd8ed1ab_0
Expand Down
10 changes: 6 additions & 4 deletions src/environment-3.10-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,10 @@ dependencies:
- liblapack=3.9.0=20_osx64_openblas
- matplotlib-inline=0.1.6=pyhd8ed1ab_0
- memory-allocator=0.1.3=py310h6729b98_0
- overrides=7.4.0=pyhd8ed1ab_0
- pexpect=4.8.0=pyh1a96a4e_2
- pip=23.3.2=pyhd8ed1ab_0
- meson=1.3.2=pyhd8ed1ab_0
- overrides=7.7.0=pyhd8ed1ab_0
- pexpect=4.9.0=pyhd8ed1ab_0
- pip=24.0=pyhd8ed1ab_0
- pplpy=0.8.9=py310hd89f7aa_0
- primecountpy=0.1.0=py310h88cfcbd_4
- prompt-toolkit=3.0.42=pyha770c72_0
Expand Down Expand Up @@ -333,7 +334,8 @@ dependencies:
- jsonschema-specifications=2023.11.2=pyhd8ed1ab_0
- jupyter_server_terminals=0.5.0=pyhd8ed1ab_0
- liblapacke=3.9.0=20_osx64_openblas
- numpy=1.26.2=py310h2a7ecf2_0
- meson-python=0.15.0=pyh0c530f3_0
- numpy=1.26.4=py310h4bfa8fc_0
- pango=1.50.14=h19c1c8a_2
- prompt_toolkit=3.0.42=hd8ed1ab_0
- pyobjc-framework-cocoa=10.1=py310h3674b6a_0
Expand Down
12 changes: 7 additions & 5 deletions src/environment-3.11-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,11 @@ dependencies:
- libxkbcommon=1.6.0=h5d7e998_0
- matplotlib-inline=0.1.6=pyhd8ed1ab_0
- memory-allocator=0.1.3=py311h459d7ec_0
- overrides=7.4.0=pyhd8ed1ab_0
- pexpect=4.8.0=pyh1a96a4e_2
- pillow=10.1.0=py311ha6c5da5_0
- pip=23.3.2=pyhd8ed1ab_0
- meson=1.3.2=pyhd8ed1ab_0
- overrides=7.7.0=pyhd8ed1ab_0
- pexpect=4.9.0=pyhd8ed1ab_0
- pillow=10.2.0=py311ha6c5da5_0
- pip=24.0=pyhd8ed1ab_0
- pplpy=0.8.9=py311h85abca9_0
- primecountpy=0.1.0=py311h9547e67_4
- prompt-toolkit=3.0.42=pyha770c72_0
Expand Down Expand Up @@ -399,7 +400,8 @@ dependencies:
- jsonschema-specifications=2023.11.2=pyhd8ed1ab_0
- jupyter_server_terminals=0.5.0=pyhd8ed1ab_0
- liblapacke=3.9.0=20_linux64_openblas
- numpy=1.26.2=py311h64a7726_0
- meson-python=0.15.0=pyh0c530f3_0
- numpy=1.26.4=py311h64a7726_0
- prompt_toolkit=3.0.42=hd8ed1ab_0
- pyqt5-sip=12.12.2=py311hb755f60_5
- requests=2.31.0=pyhd8ed1ab_0
Expand Down
10 changes: 6 additions & 4 deletions src/environment-3.11-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,10 @@ dependencies:
- liblapack=3.9.0=20_osx64_openblas
- matplotlib-inline=0.1.6=pyhd8ed1ab_0
- memory-allocator=0.1.3=py311h2725bcf_0
- overrides=7.4.0=pyhd8ed1ab_0
- pexpect=4.8.0=pyh1a96a4e_2
- pip=23.3.2=pyhd8ed1ab_0
- meson=1.3.2=pyhd8ed1ab_0
- overrides=7.7.0=pyhd8ed1ab_0
- pexpect=4.9.0=pyhd8ed1ab_0
- pip=24.0=pyhd8ed1ab_0
- pplpy=0.8.9=py311h7355a2a_0
- primecountpy=0.1.0=py311h5fe6e05_4
- prompt-toolkit=3.0.42=pyha770c72_0
Expand Down Expand Up @@ -332,7 +333,8 @@ dependencies:
- jsonschema-specifications=2023.11.2=pyhd8ed1ab_0
- jupyter_server_terminals=0.5.0=pyhd8ed1ab_0
- liblapacke=3.9.0=20_osx64_openblas
- numpy=1.26.2=py311h93c810c_0
- meson-python=0.15.0=pyh0c530f3_0
- numpy=1.26.4=py311hc43a94b_0
- pango=1.50.14=h19c1c8a_2
- prompt_toolkit=3.0.42=hd8ed1ab_0
- pyobjc-framework-cocoa=10.1=py311h9b70068_0
Expand Down
Loading
Loading