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
15 changes: 7 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,21 @@ jobs:
with:
submodules: recursive
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install --upgrade pip
pip install --upgrade -r requirements.txt
pip install --upgrade ninja
- name: Setup uv
uses: astral-sh/setup-uv@v6
- name: Build
run: pip install -v --no-build-isolation --config-settings=builddir=builddir .
run: |
uv sync --frozen --inexact -v --no-install-project
uv sync --frozen --inexact -v --no-build-isolation --no-editable --config-settings=builddir=builddir
- name: Install cypari2
run: |
sudo apt-get update
sudo apt-get install pari-gp libpari-dev
pip install --upgrade cypari2
if: matrix.os == 'ubuntu-latest'
- name: Test
run: meson test --print-errorlogs -C builddir
run: uv run --no-editable meson test --print-errorlogs -C builddir
125 changes: 36 additions & 89 deletions .github/workflows/dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,128 +11,75 @@ 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
- uses: actions/setup-python@v4
- name: Install dependencies
run: |
pip install --upgrade pip
pip install --upgrade -r requirements.txt
- uses: astral-sh/setup-uv@v6
- name: Build sdist
run: python -m build --sdist .
run: uv build --sdist
- uses: actions/upload-artifact@v4
with:
path: "dist/*.tar.*"
name: dist
- 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')
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-13
arch: x86_64
- os: macos-14
arch: arm64
env:
# SPKGs to install as system packages
SPKGS: _bootstrap _prereq
# Non-Python packages to install as spkgs
TARGETS_PRE:
# on pp310: build/src/cysignals/implementation.c:231:9: error: implicit declaration of function 'PyPyErr_SetInterrupt' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
CIBW_SKIP: "pp31*"
#
CIBW_ARCHS: ${{ matrix.arch }}
# https://cibuildwheel.readthedocs.io/en/stable/options/#requires-python
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.9"
# 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
- windows-latest
- windows-11-arm
- macos-13
- macos-latest
steps:
- uses: actions/checkout@v4
with:
repository: sagemath/sage
ref: develop

- uses: actions/download-artifact@v4
with:
name: 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.9 - 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)) || $(sage-print-system-package-command alpine --yes --no-install-recommends install $(sage-get-system-packages alpine $SPKGS)) || echo error ignored) )"
mkdir -p unpacked
for pkg in cysignals; do
(cd unpacked && tar xfz - ) < dist/$pkg*.tar.gz
"${{ steps.python.outputs.python-path }}" -m pipx run cibuildwheel==2.18.0 unpacked/$pkg*
done

- uses: astral-sh/setup-uv@v6
- name: Build wheels
uses: pypa/cibuildwheel@v3.1
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-${{ matrix.arch }}-wheels
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]
if:
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')
9 changes: 9 additions & 0 deletions example/README
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
This is a minimal working example package using cysignals.

Building this package is also part of the cysignals testsuite.

On a clear repo, and no cysignals installed anywhere, the following
works:

uv venv
source .venv/bin/activate
uv sync --frozen --inexact -v --no-install-project
uv sync --frozen --inexact -v --no-build-isolation --no-editable --config-settings=builddir=builddir
uv run --no-editable meson test --print-errorlogs -C builddir
13 changes: 1 addition & 12 deletions example/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,7 @@ project('cysignals_example', 'cython', 'cpp')

py = import('python').find_installation()

inc_cysignals = run_command(
py,
[
'-c',
'''
import cysignals
print(cysignals.__file__.replace('__init__.py', ''))
'''.strip(),
],
check: true,
).stdout().strip()
cysignals = declare_dependency(include_directories: inc_cysignals)
cysignals = dependency('cysignals')

py.extension_module('cysignals_example',
sources: ['cysignals_example.pyx'],
Expand Down
2 changes: 1 addition & 1 deletion example/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["meson-python", "cython>=0.28"]
requires = ["meson-python", "cython>=0.28", "pkgconf"]
build-backend = "mesonpy"

[project]
Expand Down
28 changes: 27 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,34 @@ classifiers = [
"Topic :: Software Development :: Debuggers",
]
urls = { Homepage = "https://github.com/sagemath/cysignals" }
requires-python = ">=3.9"
requires-python = ">=3.9,<3.14"

[project.entry-points.pkg_config]
cysignals = 'cysignals'

[tool.pytest.ini_options]
addopts = "--doctest-modules --import-mode importlib"
testpaths = "src tests"

[dependency-groups]
dev = [
"build>=1.3.0",
"cibuildwheel>=2.23.3",
"cython>=3.1.4",
"meson>=1.9.0",
"meson-python>=0.18.0",
"ninja>=1.13.0",
"pkgconf>=2.4.3.post2",
"pytest>=8.4.2",
]

[tool.cibuildwheel]
skip = ["*-win32"]
test-groups = ["dev"]
test-sources = ["tests", "pyproject.toml"]
test-command = "python -m pytest"
build-frontend = "build[uv]"
build-verbosity = 1

[tool.cibuildwheel.windows]
config-settings = { setup-args = ["--vsenv"] }
8 changes: 0 additions & 8 deletions requirements.txt

This file was deleted.

6 changes: 6 additions & 0 deletions src/cysignals/cysignals.pc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
includedir=${pcfiledir}

Name: cysignals
Description: cysignals library
Version: 1.0.0
Cflags: -I${includedir}
1 change: 1 addition & 0 deletions src/cysignals/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ configure_file(output: 'cysignals_config.h', configuration: config, install_dir:

py.install_sources(
'__init__.py',
'cysignals.pc',
'cysignals-CSI-helper.py',
'memory.pxd',
'pysignals.pxd',
Expand Down
Loading
Loading