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

pkgs/sagemath-{objects,categories,standard}: Switch to meson-python build system #37012

Draft
wants to merge 33 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
ad658e7
src/bin/sage-cython: Repurpose as PEP 420 fixer, ship with sagemath-e…
mkoeppe Jan 4, 2024
3948200
Add generate-meson.py
tobiasdiez Dec 31, 2023
903eed0
Move generate-meson.py to src/sage_setup/autogen/meson/__init__.py
mkoeppe Jan 4, 2024
7059c98
pkgs/sage-setup/pyproject.toml: Add script sage-generate-meson
mkoeppe Jan 4, 2024
fbb080b
autopep8 -i src/sage_setup/autogen/meson/__init__.py
mkoeppe Jan 4, 2024
de52fc1
sage-generate-meson: Conditionalize by distribution variables in meso…
mkoeppe Jan 5, 2024
75bff50
sage-generate-meson: Go depth-first to collect distributions
mkoeppe Jan 5, 2024
ca63147
src/sage/meson.build.in: This is src/meson.build from PR Compile ever…
tobiasdiez Jan 1, 2024
c5a1241
sage-generate-meson: Paste meson.build.in if it exists
mkoeppe Jan 5, 2024
bb984d2
src/sage/meson.build.in: Add non-auto-generated bits from other meson…
tobiasdiez Dec 31, 2023
d96efae
.gitignore: Ignore generated meson.build files
mkoeppe Jan 5, 2024
f08d1c2
sage-generate-meson: Fix up
mkoeppe Jan 5, 2024
249935d
src/sage/**/meson.build.in: Add non-auto-generated bits from other me…
tobiasdiez Dec 31, 2023
eb9bb7e
sage-generate-meson: Overwrite atomically, show diff
mkoeppe Jan 5, 2024
0dd1a3f
sage-generate-meson: Better logging
mkoeppe Jan 5, 2024
05b4db8
sage-generate-meson: Fix up creating files
mkoeppe Jan 5, 2024
e05f65d
sage-generate-meson: Add option --output-dir
mkoeppe Jan 5, 2024
f3ae437
sage-generate-meson: Add option --monolithic
mkoeppe Jan 5, 2024
a1ecf3f
sage-generate-meson: Improve option --monolithic
mkoeppe Jan 5, 2024
64a0f77
sage-generate-meson: Use install_subdir only when --monolithic
mkoeppe Jan 6, 2024
fe1318c
Merge branch 'distribution_directives' into meson-sagemath-objects
mkoeppe Jan 16, 2024
eaac674
Merge branch 'sage-namespace-cython' into meson-sagemath-objects
mkoeppe Jan 16, 2024
852986f
Merge branch 'meson-compile--generate-meson' into meson-sagemath-objects
mkoeppe Jan 16, 2024
c0484ee
pkgs/sagemath-objects: Draft meson
mkoeppe Jan 5, 2024
9aa11d9
pkgs/sagemath-objects/meson.build: Use subdir('sage')
mkoeppe Jan 5, 2024
0b1dcba
src/sage/meson.build.in: Add non-auto-generated bits from other meson…
tobiasdiez Dec 31, 2023
d7643d7
pkgs/sagemath-objects/meson.build: Fixup
mkoeppe Jan 5, 2024
f45d0f3
pkgs/sagemath-categories: Switch build system to meson-python
mkoeppe Jan 5, 2024
9f63d70
src/sage/**/meson.build.in: Add non-auto-generated bits from other me…
tobiasdiez Dec 31, 2023
bde3778
Switch pkgs/sagemath-standard ('make SAGE_WHEELS=yes sagelib') to mes…
mkoeppe Jan 5, 2024
0f0828c
pkgs/sagemath-{categories,objects,standard}: Use sage-cython-native-f…
mkoeppe Jan 6, 2024
b8a1f20
pkgs/sagemath-standard/pyproject-monolithic.toml: Fix up
mkoeppe Jan 6, 2024
bede1a8
build/pkgs/sagemath_objects/spkg-install.in: Move the std flags to CX…
mkoeppe Jan 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
/src/pyproject.toml
/src/Pipfile
/src/Pipfile.lock
/src/pyproject.toml
/Pipfile
/Pipfile.lock

Expand Down Expand Up @@ -259,6 +260,9 @@ src/*.egg-info/
/src/bin/sage-env-config
/src/bin/sage-src-env-config

# Generated by sage-generate-meson
/src/**/meson.build

# Virtual environments
/venv
src/.env
Expand Down
11 changes: 9 additions & 2 deletions build/pkgs/sagelib/spkg-install.in
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ unset SAGE_PKG_CONFIG_PATH
# spec, which includes setting a symlink to the installed documentation.
# export SAGE_DOC=/doesnotexist

if [ "$SAGE_WHEELS" = yes ]; then
# For meson
export CXX=$(echo "$CXX" | sed 's/-std=[a-z0-9+]*//g')
export CYTHON=sage-cython
export CYTHON_FOR_BUILD=sage-cython
fi

SITEPACKAGESDIR=$(python3 -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])')

export SAGE_OPTIONAL_PACKAGES_WITH_EXTENSIONS=""
Expand All @@ -57,7 +64,7 @@ if [ "$SAGE_EDITABLE" = yes ]; then

if [ "$SAGE_WHEELS" = yes ]; then
# Additionally build a wheel (for use in other venvs)
cd $SAGE_PKGS/sagelib/src && time sdh_setup_bdist_wheel && sdh_store_wheel .
cd $SAGE_PKGS/sagelib/src && time python3 -m build --no-isolation --wheel --skip-dependency-check -Csetup-args="--native-file=$(pwd)/sage-cython-native-file.ini" . && sdh_store_wheel .
fi
else
# Make sure that an installed old version of sagelib in which sage is an ordinary package
Expand All @@ -69,7 +76,7 @@ else
if [ "$SAGE_WHEELS" = yes ]; then
# Use --no-build-isolation to avoid rebuilds because of dependencies:
# Compiling sage/interfaces/sagespawn.pyx because it depends on /private/var/folders/38/wnh4gf1552g_crsjnv2vmmww0000gp/T/pip-build-env-609n5985/overlay/lib/python3.10/site-packages/Cython/Includes/posix/unistd.pxd
time sdh_pip_install --no-build-isolation .
time sdh_pip_install --no-build-isolation -Csetup-args="--native-file=$(pwd)/sage-cython-native-file.ini" .
else
SAGE_OPTIONAL_PACKAGES_WITH_EXTENSIONS+="mcqd,tdlib,coxeter3,sirocco,meataxe,bliss"
time python3 -u setup.py --no-user-cfg build install || exit 1
Expand Down
2 changes: 1 addition & 1 deletion build/pkgs/sagemath_categories/dependencies
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sagemath_objects | $(PYTHON_TOOLCHAIN) sagemath_environment sage_setup cython pkgconfig python_build $(PYTHON)
sagemath_objects | $(PYTHON_TOOLCHAIN) sagemath_environment sage_setup cython pkgconfig python_build meson_python $(PYTHON)
2 changes: 1 addition & 1 deletion build/pkgs/sagemath_objects/dependencies
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FORCE cysignals gmpy2 | $(PYTHON_TOOLCHAIN) sagemath_environment sage_setup cython pkgconfig python_build $(PYTHON)
FORCE cysignals gmpy2 | $(PYTHON_TOOLCHAIN) sagemath_environment sage_setup cython pkgconfig python_build meson_python $(PYTHON)

# FORCE: Always run the spkg-install script
12 changes: 8 additions & 4 deletions build/pkgs/sagemath_objects/spkg-install.in
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
cd src

# For meson
export CXXFLAGS="$CXXFLAGS $(echo "$CXX" | sed -En "s/.*(-std=[a-z0-9+]*).*/\1/p")"
export CXX=$(echo "$CXX" | sed 's/-std=[a-z0-9+]*//g')
export CYTHON=sage-cython
export CYTHON_FOR_BUILD=sage-cython


export PIP_NO_INDEX=true
export PIP_FIND_LINKS="file://$SAGE_SPKG_WHEELS"

# First build the sdist, then build the wheel from the sdist.
# https://pypa-build.readthedocs.io/en/latest/#python--m-build
# (Important because sagemath-objects uses MANIFEST.in for filtering.)
# Do not install the wheel.
DIST_DIR="$(mktemp -d)"
python3 -m build --outdir "$DIST_DIR"/dist . || sdh_die "Failure building sdist and wheel"
python3 -m build --no-isolation --wheel --skip-dependency-check -Csetup-args="--native-file=$(pwd)/sage-cython-native-file.ini" --outdir "$DIST_DIR"/dist . || sdh_die "Failure building sdist and wheel"

wheel=$(cd "$DIST_DIR" && sdh_store_wheel . >&2 && echo $wheel)
ls -l "$wheel"
4 changes: 4 additions & 0 deletions pkgs/sage-setup/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,16 @@ content-type = "text/x-rst"
[project.optional-dependencies]
autogen = ["jinja2"]

[project.scripts]
sage-generate-meson = "sage_setup.autogen.meson:generate_meson"

[tool.setuptools]
packages = [
"sage_setup",
"sage_setup.autogen",
"sage_setup.autogen.interpreters",
"sage_setup.autogen.interpreters.specs",
"sage_setup.autogen.meson",
"sage_setup.command",
]
include-package-data = false
Expand Down
21 changes: 21 additions & 0 deletions pkgs/sagemath-categories/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
project(
'sagemath-categories',
['c', 'cpp', 'cython'],
version: files('VERSION.txt'),
meson_version: '>= 1.2.0',
)

set_variable('distribution_sagemath_categories', true)

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

# Compilers
cc = meson.get_compiler('c')
cpp = meson.get_compiler('cpp')
cython = meson.get_compiler('cython')

subdir('sage')
5 changes: 2 additions & 3 deletions pkgs/sagemath-categories/pyproject.toml.m4
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ include(`sage_spkg_versions_toml.m4')dnl' -*- conf-toml -*-
[build-system]
# Minimum requirements for the build system to execute.
requires = [
SPKG_INSTALL_REQUIRES_setuptools
SPKG_INSTALL_REQUIRES_wheel
SPKG_INSTALL_REQUIRES_meson_python
SPKG_INSTALL_REQUIRES_sage_setup
SPKG_INSTALL_REQUIRES_sagemath_environment
SPKG_INSTALL_REQUIRES_sagemath_objects
Expand All @@ -12,7 +11,7 @@ requires = [
SPKG_INSTALL_REQUIRES_cysignals
SPKG_INSTALL_REQUIRES_pkgconfig
]
build-backend = "setuptools.build_meta"
build-backend = "mesonpy"

[project]
name = "sagemath-categories"
Expand Down
1 change: 1 addition & 0 deletions pkgs/sagemath-categories/sage-cython-native-file.ini
3 changes: 3 additions & 0 deletions pkgs/sagemath-environment/pyproject.toml.m4
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ script-files = [
"bin/sage-version.sh",
# Auxiliary script for invoking Python in the Sage environment
"bin/sage-python",
# The following is freshly un-deprecated as a temporary workaround
# for defects in Cython 3.0.x support for PEP 420 implicit namespace packages
"bin/sage-cython",
# Not included:
# - bin/sage-env-config -- installed by sage_conf
# - bin/sage-env-config.in -- not to be installed
Expand Down
21 changes: 21 additions & 0 deletions pkgs/sagemath-objects/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
project(
'sagemath-objects',
['c', 'cpp', 'cython'],
version: files('VERSION.txt'),
meson_version: '>= 1.2.0',
)

set_variable('distribution_sagemath_objects', true)

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

# Compilers
cc = meson.get_compiler('c')
cpp = meson.get_compiler('cpp')
cython = meson.get_compiler('cython')

subdir('sage')
5 changes: 2 additions & 3 deletions pkgs/sagemath-objects/pyproject.toml.m4
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ include(`sage_spkg_versions_toml.m4')dnl' -*- conf-toml -*-
[build-system]
# Minimum requirements for the build system to execute.
requires = [
SPKG_INSTALL_REQUIRES_setuptools
SPKG_INSTALL_REQUIRES_wheel
SPKG_INSTALL_REQUIRES_meson_python
SPKG_INSTALL_REQUIRES_sage_setup
SPKG_INSTALL_REQUIRES_sagemath_environment
SPKG_INSTALL_REQUIRES_cython
SPKG_INSTALL_REQUIRES_gmpy2
SPKG_INSTALL_REQUIRES_cysignals
SPKG_INSTALL_REQUIRES_pkgconfig
]
build-backend = "setuptools.build_meta"
build-backend = "mesonpy"

[project]
name = "sagemath-objects"
Expand Down
2 changes: 2 additions & 0 deletions pkgs/sagemath-objects/sage-cython-native-file.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[binaries]
cython = 'sage-cython'
50 changes: 50 additions & 0 deletions pkgs/sagemath-standard/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
project(
'sagemath-standard',
['c', 'cpp', 'cython'],
version: files('VERSION.txt'),
meson_version: '>= 1.2.0',
)

# same list in setup.py
set_variable('distribution_', true) # catch-all
set_variable('distribution_sagemath_objects', true)
set_variable('distribution_sagemath_brial', true)
set_variable('distribution_sagemath_categories', true)
set_variable('distribution_sagemath_combinat', true)
set_variable('distribution_sagemath_eclib', true)
set_variable('distribution_sagemath_environment', true)
set_variable('distribution_sagemath_flint', true)
set_variable('distribution_sagemath_gap', true)
set_variable('distribution_sagemath_giac', true)
set_variable('distribution_sagemath_glpk', true)
set_variable('distribution_sagemath_graphs', true)
set_variable('distribution_sagemath_groups', true)
set_variable('distribution_sagemath_homfly', true)
set_variable('distribution_sagemath_lcalc', true)
set_variable('distribution_sagemath_libbraiding', true)
set_variable('distribution_sagemath_libecm', true)
set_variable('distribution_sagemath_linbox', true)
set_variable('distribution_sagemath_modules', true)
set_variable('distribution_sagemath_mpmath', true)
set_variable('distribution_sagemath_ntl', true)
set_variable('distribution_sagemath_objects', true)
set_variable('distribution_sagemath_pari', true)
set_variable('distribution_sagemath_plot', true)
set_variable('distribution_sagemath_polyhedra', true)
set_variable('distribution_sagemath_repl', true)
set_variable('distribution_sagemath_schemes', true)
set_variable('distribution_sagemath_singular', true)
set_variable('distribution_sagemath_symbolics', true)

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

# Compilers
cc = meson.get_compiler('c')
cpp = meson.get_compiler('cpp')
cython = meson.get_compiler('cython')

subdir('sage')
1 change: 1 addition & 0 deletions pkgs/sagemath-standard/pyproject-monolithic.toml
1 change: 1 addition & 0 deletions pkgs/sagemath-standard/pyproject-monolithic.toml.m4
1 change: 0 additions & 1 deletion pkgs/sagemath-standard/pyproject.toml

This file was deleted.

Loading
Loading