Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
140 changes: 43 additions & 97 deletions .github/workflows/dist.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build wheels
name: Distribution

on:
push:
Expand All @@ -11,131 +11,77 @@ concurrency:
cancel-in-progress: true

jobs:

sdists_for_pypi:
name: Build sdist (and upload to PyPI on release tags)
make_sdist:
name: Build sdist
runs-on: ubuntu-latest
env:
CAN_DEPLOY: ${{ secrets.SAGEMATH_PYPI_API_TOKEN != '' }}
steps:
- uses: actions/checkout@v4
- name: Install pari
run: |
bash -x .install-pari.sh
env:
PARI_VERSION: pari-2.17.1
URLDIR: unix
- uses: actions/setup-python@v4
- name: make sdist
run: |
python3 -m pip install build
python3 -m build --sdist
- uses: astral-sh/setup-uv@v6
- name: Install PARI
run: ./.install-pari.sh
- name: Build sdist
run: uv build --sdist
- uses: actions/upload-artifact@v4
with:
path: "dist/*.tar.gz"
name: dist-ubuntu-latest
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.SAGEMATH_PYPI_API_TOKEN }}
skip_existing: true
verbose: true
if: env.CAN_DEPLOY == 'true' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
path: "dist/*.tar.*"
name: release-sdist

build_wheels:
name: Build wheels on ${{ matrix.os }}, arch ${{ matrix.arch }}
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: sdists_for_pypi
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
arch: x86_64
- os: ubuntu-latest
arch: i686
- os: macos-latest
arch: auto
- os: macos-14
arch: auto
env:
# SPKGs to install as system packages
SPKGS: _bootstrap _prereq
# Non-Python packages to install as spkgs
TARGETS_PRE: pari
# Disable building PyPy wheels on all platforms
# Disable musllinux until #33083 provides alpine package information
CIBW_SKIP: "pp* *-musllinux*"
#
CIBW_ARCHS: ${{ matrix.arch }}
# https://cibuildwheel.readthedocs.io/en/stable/options/#requires-python
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.10"
# Environment during wheel build
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"
# Use 'build', not 'pip wheel'
CIBW_BUILD_FRONTEND: build
os:
- ubuntu-latest
- ubuntu-24.04-arm
- macos-13
- macos-latest
steps:
- uses: actions/checkout@v4
with:
repository: sagemath/sage
ref: develop

- uses: actions/download-artifact@v4
with:
pattern: dist-*
path: dist

- uses: actions/setup-python@v5
# As of 2024-02-03, the macOS M1 runners do not have preinstalled python or pipx.
# Installing pipx follows the approach of https://github.com/pypa/cibuildwheel/pull/1743
id: python
with:
python-version: "3.10 - 3.12"
update-environment: false

- name: Build platform wheels
# We build the wheel from the sdist.
# But we must run cibuildwheel with the unpacked source directory, not a tarball,
# so that SAGE_ROOT is copied into the build containers.
#
# In the CIBW_BEFORE_ALL phase, we install libraries using the Sage distribution.
# https://cibuildwheel.readthedocs.io/en/stable/options/#before-all
run: |
"${{ steps.python.outputs.python-path }}" -m pip install pipx
export PATH=build/bin:$PATH
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)) || echo error ignored) ) && ./bootstrap && ./configure --enable-build-as-root && make -j4 V=0 $TARGETS_PRE"
mkdir -p unpacked
for pkg in cypari2; do
(cd unpacked && tar xfz - ) < dist/dist-ubuntu-latest/$pkg*.tar.gz
"${{ steps.python.outputs.python-path }}" -m pipx run cibuildwheel==2.17.0 unpacked/$pkg*
done

- uses: astral-sh/setup-uv@v6
- name: Build wheels
uses: pypa/cibuildwheel@v3.1
env:
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.12, <3.14"
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.os == 'macos-latest' && '15.0' || '13.0' }}
- uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}-${{ matrix.arch }}
path: ./wheelhouse/*.whl
name: release-wheels-${{ matrix.os }}
path: wheelhouse/*.whl

pypi-publish:
# This needs to be a separate job because pypa/gh-action-pypi-publish cannot run on macOS
# https://github.com/pypa/gh-action-pypi-publish
name: Upload wheels to PyPI
needs: build_wheels
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
needs: [build_wheels, make_sdist]
runs-on: ubuntu-latest
env:
CAN_DEPLOY: ${{ secrets.SAGEMATH_PYPI_API_TOKEN != '' }}
permissions:
id-token: write
attestations: write
contents: read
steps:

- uses: actions/download-artifact@v4
with:
pattern: wheels-*
path: wheelhouse
pattern: release-*
path: dist
merge-multiple: true

- name: List files
run: ls -l -R dist

- name: Generate artifact attestations
uses: actions/attest-build-provenance@v2
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
with:
subject-path: "dist/*"

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.SAGEMATH_PYPI_API_TOKEN }}
packages-dir: wheelhouse/
skip_existing: true
verbose: true
if: env.CAN_DEPLOY == 'true'
if: env.CAN_DEPLOY == 'true' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
142 changes: 85 additions & 57 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: cypari2
name: CI

on:
pull_request:
Expand All @@ -15,78 +15,106 @@ concurrency:

jobs:
build:
name: Build and Test (${{ matrix.os }}, Python ${{ matrix.python-version }}, PARI ${{ matrix.pari-version }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ['3.10', '3.11', '3.12', '3.13']
pari-version: ['pari-2.13.0', 'pari-2.15.4', 'pari-2.15.5', '2.17.2']
python-version: ['3.12', '3.13']
pari-version: ['2.13.0', '2.15.4', '2.15.5', '2.17.2']
include:
- os: macos-latest
python-version: '3.12'
pari-version: '2.17.2' # Whatever comes with homebrew
- os: macos-latest
python-version: '3.13'
pari-version: '2.17.2' # Whatever comes with homebrew
env:
LC_ALL: C
PARI_VERSION: ${{ matrix.pari-version }}
defaults:
run:
shell: ${{ matrix.os == 'windows-latest' && 'msys2 {0}' || 'bash' }}
steps:
- name: Set up the repository
uses: actions/checkout@v4
- name: Setup MSYS2
if: runner.os == 'Windows'
id: msys2
uses: msys2/setup-msys2@v2
with:
msystem: UCRT64
update: true
install: >-
base-devel
m4
bison
make
patch
sed
wget
mingw-w64-ucrt-x86_64-toolchain
mingw-w64-ucrt-x86_64-gmp
mingw-w64-ucrt-x86_64-python
mingw-w64-ucrt-x86_64-python-pip
mingw-w64-ucrt-x86_64-meson-python
mingw-w64-ucrt-x86_64-cython
path-type: inherit
- name: Set up Python ${{ matrix.python-version }}
if: runner.os != 'Windows'
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install pari
- name: Install PARI
if: matrix.os != 'macos-latest'
run: |
bash -x .install-pari.sh
- name: Install PARI
if: matrix.os == 'macos-latest'
run: |
bash -x .install-pari.sh
- name: Local build
brew install pari
- name: Smoke test PARI
run: |
make install
make check
pip install sphinx
(cd docs && make html)

dist:
runs-on: ubuntu-latest
steps:
- name: Check out ${{ env.SPKG }}
uses: actions/checkout@v4
with:
path: build/pkgs/${{ env.SPKG }}/src
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
- name: Install prerequisites
run: |
sudo DEBIAN_FRONTEND=noninteractive apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get install $DIST_PREREQ
python3 -m pip install build
- name: Run make dist, prepare upstream artifact
run: |
(cd build/pkgs/${{ env.SPKG }}/src && python3 -m build --sdist) \
&& mkdir -p upstream && cp build/pkgs/${{ env.SPKG }}/src/dist/*.tar.gz upstream/${{ env.SPKG }}-git.tar.gz \
&& echo "sage-package create ${{ env.SPKG }} --version git --tarball ${{ env.SPKG }}-git.tar.gz --type=standard" > upstream/update-pkgs.sh \
&& if [ -n "${{ env.REMOVE_PATCHES }}" ]; then echo "(cd ../build/pkgs/${{ env.SPKG }}/patches && rm -f ${{ env.REMOVE_PATCHES }}; :)" >> upstream/update-pkgs.sh; fi \
&& ls -l upstream/
- uses: actions/upload-artifact@v4
with:
path: upstream
name: upstream
if [ ${{ runner.os }} = macOS ]; then
HOMEBREW=`brew --prefix`
clang -v tests/test.c -o test -I$HOMEBREW/include -L$HOMEBREW/lib -lpari -lgmp
else
gcc -v tests/test.c -o test -I/usr/local/include -L/usr/local/bin -lpari -lgmp
fi
expected="zeta(2) = 1.6449340668482264364
p = x^3 + x^2 + x - 1
modulus = y^3 + y^2 + y - 1
centerlift(lift(fq)) = [x - y, 1; x + (y^2 + y - 1), 1; x + (-y^2 - 1), 1]"
output="$(./test)"
# Normalize newlines for comparison
output="$(echo "$output" | tr -d '\r')"
expected="$(echo "$expected" | tr -d '\r')"
echo -e "Got:\n$output"
if [ "$output" != "$expected" ]; then
echo "Unexpected output from test.c"
echo -e "Expected:\n$expected"
exit 1
fi

sage:
uses: sagemath/sage/.github/workflows/docker.yml@develop
with:
targets: SAGE_CHECK=no SAGE_CHECK_PACKAGES="cypari" cypari
targets_optional: build/make/Makefile
sage_repo: sagemath/sage
sage_ref: develop
upstream_artifact: upstream
# We prefix the image name with the SPKG name ("cypari2-") to avoid the error
# 'Package "sage-docker-..." is already associated with another repository.'
docker_push_repository: ghcr.io/${{ github.repository }}/cypari2-
tox_packages_factors: >-
["standard"]
needs: [dist]
- name: Setup uv
uses: astral-sh/setup-uv@v6

env:
# Ubuntu packages to install so that building the sdist can succeed
DIST_PREREQ: libpari-dev pari-doc libbz2-dev bzip2
# Name of this project in the Sage distribution
SPKG: cypari
# Remove all downstream patches
REMOVE_PATCHES: "*"
- name: Build
run: |
if [ ${{ runner.os }} = Windows ]; then
export C_INCLUDE_PATH=$(cygpath -am "${{ steps.msys2.outputs.msys2-location }}")/usr/local/include
export LIBRARY_PATH=$(cygpath -am "${{ steps.msys2.outputs.msys2-location }}")/usr/local/bin
fi
echo $PATH
echo $C_INCLUDE_PATH
echo $LIBRARY_PATH
uv sync --frozen --inexact -v --no-install-project
uv sync --frozen --inexact -v --no-build-isolation --no-editable --config-settings=builddir=builddir
- name: Test
run: |
uv run make check
- name: Build docs
run: |
uv sync --frozen --inexact -v --group doc
(cd docs && uv run make html)
17 changes: 0 additions & 17 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@
# Autogenerated files
# (either by Cython or autogen)
cypari2/auto_gen.pxi.tmp
cypari2/auto_gen.pxi
cypari2/auto_instance.pxi.tmp
cypari2/auto_instance.pxi
cypari2/auto_paridecl.pxd.tmp
cypari2/auto_paridecl.pxd
cypari2/closure.c
cypari2/convert.c
cypari2/custom_block.c
cypari2/gen.c
cypari2/handle_error.c
cypari2/pari_instance.c
cypari2/stack.c
cypari2/string_utils.c

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
Loading