Skip to content

Commit 3600dd7

Browse files
committed
Migrate to meson build system with bundled PPL 1.2
- Replace setuptools with meson-python build backend - Bundle PPL 1.2 source in subprojects/ppl-1.2/ - Compile PPL as static library with C++23 standard - Fix std::auto_ptr -> std::unique_ptr for C++23 compatibility - Fix deprecated std::iterator inheritance in PPL headers - Add meson.build files for root project, PPL subproject, ppl/ extensions, and tests/ - Add ppl-config.h.mesondefine for meson feature detection - Register all tests (doctests, unittest, Cython integration) via meson test - Update all GitHub Actions workflows (test, doc, dist) for meson build - Remove external PPL dependency from environment files - Use trusted publishing for PyPI uploads - Simplify cibuildwheel config (PPL bundled, only need system GMP)
1 parent 55cf3c1 commit 3600dd7

File tree

439 files changed

+270458
-138
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

439 files changed

+270458
-138
lines changed

.github/workflows/dist.yml

Lines changed: 48 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -2,123 +2,99 @@ name: Distributions
22

33
on:
44
push:
5+
branches: [ "master", "meson" ]
6+
tags: [ "*" ]
57
pull_request:
68
workflow_dispatch:
79

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

1314
jobs:
1415

15-
sdists_for_pypi:
16-
name: Build sdist (and upload to PyPI on release tags)
16+
sdist:
17+
name: Build sdist
1718
runs-on: ubuntu-latest
18-
env:
19-
CAN_DEPLOY: ${{ secrets.SAGEMATH_PYPI_API_TOKEN != '' }}
2019
steps:
2120
- uses: actions/checkout@v4
22-
- uses: actions/setup-python@v4
23-
- name: make sdist
21+
22+
- uses: actions/setup-python@v5
23+
with:
24+
python-version: "3.13"
25+
26+
- name: Install system dependencies
2427
run: |
25-
python3 -m pip install build
26-
python3 -m build --sdist
28+
sudo apt-get update
29+
sudo apt-get install -y libgmp-dev libmpfr-dev libmpc-dev
30+
31+
- name: Build sdist
32+
run: |
33+
pip install build
34+
python -m build --sdist
35+
2736
- uses: actions/upload-artifact@v5
2837
with:
29-
path: "dist/*.tar.gz"
30-
name: dist
31-
- uses: pypa/gh-action-pypi-publish@release/v1
32-
with:
33-
user: __token__
34-
password: ${{ secrets.SAGEMATH_PYPI_API_TOKEN }}
35-
skip_existing: true
36-
verbose: true
37-
if: env.CAN_DEPLOY == 'true' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
38+
name: dist-sdist
39+
path: dist/*.tar.gz
3840

3941
build_wheels:
4042
name: Build wheels on ${{ matrix.os }}
4143
runs-on: ${{ matrix.os }}
42-
needs: sdists_for_pypi
44+
needs: sdist
4345
strategy:
4446
fail-fast: false
4547
matrix:
4648
os:
4749
- ubuntu-latest
4850
- macos-latest
4951
- ubuntu-24.04-arm
50-
- macos-15-intel
5152
env:
52-
# SPKGs to install as system packages
53-
SPKGS: _bootstrap _prereq gmp mpfr mpc
54-
# Non-Python packages to install as spkgs
55-
TARGETS_PRE: gmp mpfr mpc ppl-ensure
56-
# Environment during wheel build
57-
CIBW_ENVIRONMENT: "PATH=$(pwd)/local/bin:$PATH CPATH=$(pwd)/local/include:$CPATH LIBRARY_PATH=$(pwd)/local/lib:$LIBRARY_PATH LD_LIBRARY_PATH=$(pwd)/local/lib:$LD_LIBRARY_PATH PKG_CONFIG_PATH=$(pwd)/local/share/pkgconfig:$PKG_CONFIG_PATH ACLOCAL_PATH=/usr/share/aclocal"
58-
# Use 'build', not 'pip wheel'
53+
CIBW_BUILD: "cp312-* cp313-* cp314-*"
54+
CIBW_SKIP: "*-musllinux*"
55+
CIBW_BEFORE_BUILD_LINUX: >-
56+
yum install -y gmp-devel || apt-get install -y libgmp-dev
57+
CIBW_BEFORE_BUILD_MACOS: >-
58+
brew install gmp
59+
CIBW_ENVIRONMENT_MACOS: >-
60+
CPATH=$(brew --prefix gmp)/include:$CPATH
61+
LIBRARY_PATH=$(brew --prefix gmp)/lib:$LIBRARY_PATH
5962
CIBW_BUILD_FRONTEND: build
63+
CIBW_TEST_COMMAND: >-
64+
python {project}/tests/runtests.py
6065
steps:
6166
- uses: actions/checkout@v4
62-
with:
63-
repository: sagemath/sage
64-
ref: develop
65-
66-
- uses: actions/download-artifact@v6
67-
with:
68-
name: dist
69-
path: dist
7067

7168
- uses: actions/setup-python@v5
72-
# As of 2024-02-03, the macOS M1 runners do not have preinstalled python or pipx.
73-
# Installing pipx follows the approach of https://github.com/pypa/cibuildwheel/pull/1743
74-
id: python
7569
with:
76-
python-version: "3.12 - 3.14"
77-
update-environment: false
70+
python-version: "3.13"
7871

79-
- name: Build platform wheels
80-
# We build the wheel from the sdist.
81-
# But we must run cibuildwheel with the unpacked source directory, not a tarball,
82-
# so that SAGE_ROOT is copied into the build containers.
83-
#
84-
# In the CIBW_BEFORE_ALL phase, we install libraries using the Sage distribution.
85-
# https://cibuildwheel.readthedocs.io/en/stable/options/#before-all
86-
run: |
87-
"${{ steps.python.outputs.python-path }}" -m pip install pipx
88-
export PATH=build/bin:$PATH
89-
export CIBW_BEFORE_ALL="( $(sage-print-system-package-command debian --yes --no-install-recommends install $(sage-get-system-packages debian $SPKGS)) || $(sage-print-system-package-command fedora --yes --no-install-recommends install $(sage-get-system-packages fedora $SPKGS | sed s/pkg-config/pkgconfig/)) || ( $(sage-print-system-package-command homebrew --yes --no-install-recommends install $(sage-get-system-packages homebrew $SPKGS)) || $(sage-print-system-package-command alpine --yes --no-install-recommends install $(sage-get-system-packages alpine $SPKGS)) || echo error ignored) ) && ./bootstrap && ./configure --enable-build-as-root --enable-fat-binary --disable-meson-check --disable-boost && MAKE=\"make -j6\" make V=0 $TARGETS_PRE"
90-
mkdir -p unpacked
91-
for pkg in pplpy; do
92-
(cd unpacked && tar xfz - ) < dist/$pkg*.tar.gz
93-
"${{ steps.python.outputs.python-path }}" -m pipx run cibuildwheel==3.2.1 unpacked/$pkg*
94-
done
72+
- name: Build wheels
73+
uses: pypa/cibuildwheel@v2.23
74+
with:
75+
output-dir: wheelhouse
9576

9677
- uses: actions/upload-artifact@v5
9778
with:
9879
name: wheels-${{ matrix.os }}
9980
path: ./wheelhouse/*.whl
10081

101-
pypi-publish:
102-
# https://github.com/pypa/gh-action-pypi-publish
103-
name: Upload wheels to PyPI
104-
needs: build_wheels
82+
pypi_publish:
83+
name: Upload to PyPI
84+
needs: [sdist, build_wheels]
10585
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
10686
runs-on: ubuntu-latest
107-
env:
108-
CAN_DEPLOY: ${{ secrets.SAGEMATH_PYPI_API_TOKEN != '' }}
87+
environment: pypi
88+
permissions:
89+
id-token: write
10990
steps:
110-
11191
- uses: actions/download-artifact@v6
11292
with:
113-
name: wheels
114-
path: wheelhouse
93+
path: dist
94+
merge-multiple: true
11595

116-
- name: Publish package distributions to PyPI
117-
uses: pypa/gh-action-pypi-publish@release/v1
96+
- uses: pypa/gh-action-pypi-publish@release/v1
11897
with:
119-
user: __token__
120-
password: ${{ secrets.SAGEMATH_PYPI_API_TOKEN }}
121-
packages_dir: wheelhouse/
122-
skip_existing: true
98+
packages-dir: dist/
99+
skip-existing: true
123100
verbose: true
124-
if: env.CAN_DEPLOY == 'true'

.github/workflows/doc.yml

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Documentation
22
on:
3-
push: { branches: [ "master" ] }
3+
push: { branches: [ "master", "meson" ] }
44
pull_request: { branches: [ "master" ] }
55

66
concurrency:
@@ -11,40 +11,47 @@ jobs:
1111
build-manual:
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v2
15-
with: { submodules: recursive }
16-
- uses: conda-incubator/setup-miniconda@v2
17-
with: { miniforge-variant: "Mambaforge", miniforge-version: "latest" }
18-
- name: Install pplpy dependencies
19-
shell: bash -l {0}
14+
- uses: actions/checkout@v4
15+
16+
- uses: actions/setup-python@v5
17+
with:
18+
python-version: "3.13"
19+
20+
- name: Install system dependencies
2021
run: |
21-
mamba env update --quiet -n test -f environment.yml
22-
conda list
22+
sudo apt-get update
23+
sudo apt-get install -y libgmp-dev libmpfr-dev libmpc-dev
24+
25+
- name: Install Python build dependencies
26+
run: |
27+
pip install --upgrade pip
28+
pip install meson-python meson ninja cython cysignals "gmpy2>=2.1.0b1"
29+
2330
- name: Install pplpy
24-
shell: bash -l {0}
2531
run: |
26-
pip install --verbose --no-index --no-build-isolation .
27-
- name: Install test dependencies
32+
pip install --no-build-isolation --verbose .
33+
34+
- name: Install doc dependencies
2835
run: |
29-
mamba env update --quiet -n test -f environment.test.yml
30-
conda list
36+
pip install sphinx linkchecker
37+
3138
- name: Build documentation
32-
shell: bash -l {0}
33-
run:
39+
run: |
3440
sphinx-build docs/source html/pplpy
41+
3542
- name: Detect broken links
36-
shell: bash -l {0}
3743
run: |
3844
python -m http.server 8880 --directory html &
3945
sleep 1
4046
# We ignore _modules since sphinx puts all modules in the module
4147
# overview but does not generate pages for .pyx modules.
42-
# We also ignore a url that is generated by sphinx itself (version 7.2.6).
48+
# We also ignore a url that is generated by sphinx itself.
4349
linkchecker --check-extern --ignore-url='_modules/|https://www.sphinx-doc.org/' http://localhost:8880
44-
- uses: JamesIves/github-pages-deploy-action@3.7.1
50+
51+
- uses: JamesIves/github-pages-deploy-action@v4
4552
with:
46-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47-
BRANCH: gh-pages
48-
FOLDER: html/pplpy/
49-
TARGET_FOLDER: docs/
53+
token: ${{ secrets.GITHUB_TOKEN }}
54+
branch: gh-pages
55+
folder: html/pplpy/
56+
target-folder: docs/
5057
if: ${{ github.event_name == 'push' }}

.github/workflows/test.yml

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Test
22
on:
3-
push: { branches: [ "master" ] }
3+
push: { branches: [ "master", "meson" ] }
44
pull_request: { branches: [ "master" ] }
55

66
concurrency:
@@ -15,45 +15,43 @@ jobs:
1515
matrix:
1616
python: ["3.12", "3.13", "3.14"]
1717
steps:
18-
- uses: actions/checkout@v2
19-
with: { submodules: recursive }
18+
- uses: actions/checkout@v4
2019

21-
- name: Setup Conda environment
22-
uses: conda-incubator/setup-miniconda@v3
20+
- uses: actions/setup-python@v5
2321
with:
2422
python-version: ${{ matrix.python }}
25-
# Disabled for now due to
26-
# https://github.com/conda-incubator/setup-miniconda/issues/379
27-
# miniforge-version: latest
28-
use-mamba: true
29-
channels: conda-forge
30-
channel-priority: true
31-
32-
- name: Install dependencies
33-
shell: bash -l {0}
23+
24+
- name: Install system dependencies
25+
run: |
26+
sudo apt-get update
27+
sudo apt-get install -y libgmp-dev libmpfr-dev libmpc-dev
28+
29+
- name: Install Python build dependencies
3430
run: |
35-
conda install --quiet ppl gmp mpfr mpc
31+
pip install --upgrade pip
32+
pip install meson-python meson ninja cython cysignals "gmpy2>=2.1.0b1"
3633
37-
- name: Build
38-
shell: bash -l {0}
34+
- name: Build and install
3935
run: |
40-
pip install --verbose .
36+
pip install --no-build-isolation --verbose .
4137
4238
- name: Install test dependencies
4339
run: |
44-
conda env update --quiet -n test -f environment.test.yml
45-
conda list
40+
pip install sphinx cython-lint
4641
4742
- name: Lint
48-
shell: bash -l {0}
4943
run: |
5044
cython-lint --ignore=E265,E266,E501,E741 --exclude='ppl_decl.pxd' ppl/
5145
52-
- name: Run tests
53-
shell: bash -l {0}
46+
- name: Build (meson)
47+
run: |
48+
meson setup builddir
49+
meson compile -C builddir
50+
51+
- name: Test (meson test)
5452
run: |
55-
python setup.py test
53+
meson test -C builddir -v
5654
5755
- name: Show logs
58-
run: grep "" /dev/null `find -name '*.log'` || true
56+
run: cat builddir/meson-logs/testlog.txt || true
5957
if: ${{ always() }}

environment.test.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ channels:
55
dependencies:
66
- sphinx
77
- pip
8-
- setuptools
98
- pip:
109
- linkchecker
11-
- cython-lint
10+
- cython-lint

environment.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ channels:
33
- conda-forge
44
- defaults
55
dependencies:
6-
- setuptools
6+
- meson
7+
- meson-python
78
- gmpy2
89
- cysignals
910
- cython
10-
- ppl

meson.build

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
project('pplpy', 'cpp', 'cython',
2+
version: '0.8.10',
3+
default_options: [
4+
'cpp_std=c++23',
5+
],
6+
)
7+
8+
# ---------- Python ----------
9+
py = import('python').find_installation(pure: false)
10+
11+
# ---------- PPL (bundled subproject) ----------
12+
ppl_proj = subproject('ppl-1.2')
13+
ppl_dep = ppl_proj.get_variable('ppl_dep')
14+
15+
# ---------- Build the ppl package ----------
16+
subdir('ppl')
17+
18+
# ---------- Tests ----------
19+
subdir('tests')

0 commit comments

Comments
 (0)