cypari2 2.2.4__tar.gz → 2.2.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. cypari2-2.2.7/.github/check-distributions.py +80 -0
  2. cypari2-2.2.7/.github/check-installed.py +45 -0
  3. cypari2-2.2.7/.github/setup-brew-pari.sh +45 -0
  4. cypari2-2.2.7/.github/test_distribution_checks.py +74 -0
  5. cypari2-2.2.7/.github/verify-sdist.py +35 -0
  6. cypari2-2.2.7/.github/workflows/dist.yml +210 -0
  7. {cypari2-2.2.4 → cypari2-2.2.7}/.github/workflows/main.yml +47 -28
  8. {cypari2-2.2.4 → cypari2-2.2.7}/.install-pari.sh +126 -2
  9. {cypari2-2.2.4 → cypari2-2.2.7}/Makefile +1 -4
  10. {cypari2-2.2.4 → cypari2-2.2.7}/NEWS +34 -0
  11. {cypari2-2.2.4 → cypari2-2.2.7}/PKG-INFO +5 -5
  12. {cypari2-2.2.4 → cypari2-2.2.7}/README.rst +2 -2
  13. {cypari2-2.2.4 → cypari2-2.2.7}/autogen/args.py +1 -1
  14. {cypari2-2.2.4 → cypari2-2.2.7}/autogen/doc.py +1 -1
  15. {cypari2-2.2.4 → cypari2-2.2.7}/autogen/generator.py +21 -3
  16. cypari2-2.2.7/benchmarks/thread_dispatch.py +64 -0
  17. cypari2-2.2.7/cypari2/__init__.py +21 -0
  18. cypari2-2.2.7/cypari2/_thread_runtime.py +367 -0
  19. {cypari2-2.2.4 → cypari2-2.2.7}/cypari2/closure.pyx +79 -21
  20. {cypari2-2.2.4 → cypari2-2.2.7}/cypari2/convert.pyx +24 -2
  21. {cypari2-2.2.4 → cypari2-2.2.7}/cypari2/custom_block.pyx +9 -0
  22. {cypari2-2.2.4 → cypari2-2.2.7}/cypari2/cypari.h +12 -0
  23. {cypari2-2.2.4 → cypari2-2.2.7}/cypari2/gen.pyx +315 -48
  24. {cypari2-2.2.4 → cypari2-2.2.7}/cypari2/handle_error.pyx +5 -2
  25. {cypari2-2.2.4 → cypari2-2.2.7}/cypari2/meson.build +16 -3
  26. {cypari2-2.2.4 → cypari2-2.2.7}/cypari2/pari_instance.pxd +1 -1
  27. {cypari2-2.2.4 → cypari2-2.2.7}/cypari2/pari_instance.pyx +190 -34
  28. {cypari2-2.2.4 → cypari2-2.2.7}/cypari2/paridecl.pxd +0 -1
  29. {cypari2-2.2.4 → cypari2-2.2.7}/cypari2/stack.pxd +1 -0
  30. {cypari2-2.2.4 → cypari2-2.2.7}/cypari2/stack.pyx +46 -19
  31. cypari2-2.2.7/cypari2/thread_support.pxd +7 -0
  32. cypari2-2.2.7/cypari2/thread_support.pyx +259 -0
  33. {cypari2-2.2.4 → cypari2-2.2.7}/cypari2/types.pxd +1 -1
  34. {cypari2-2.2.4 → cypari2-2.2.7}/docs/source/conf.py +5 -1
  35. {cypari2-2.2.4 → cypari2-2.2.7}/docs/source/index.rst +1 -0
  36. cypari2-2.2.7/docs/source/threading.rst +95 -0
  37. {cypari2-2.2.4 → cypari2-2.2.7}/meson.build +65 -40
  38. cypari2-2.2.7/meson.options +2 -0
  39. {cypari2-2.2.4 → cypari2-2.2.7}/pyproject.toml +18 -9
  40. {cypari2-2.2.4 → cypari2-2.2.7}/tests/rundoctest.py +3 -0
  41. cypari2-2.2.7/tests/subprocess_helpers.py +22 -0
  42. {cypari2-2.2.4 → cypari2-2.2.7}/tests/test.pyx +32 -0
  43. {cypari2-2.2.4 → cypari2-2.2.7}/tests/test_backward.py +13 -0
  44. cypari2-2.2.7/tests/test_callback_regressions.py +67 -0
  45. cypari2-2.2.7/tests/test_operator_regressions.py +92 -0
  46. cypari2-2.2.7/tests/test_precision.py +151 -0
  47. cypari2-2.2.7/tests/test_runtime_regressions.py +122 -0
  48. cypari2-2.2.7/tests/test_signal_regressions.py +99 -0
  49. cypari2-2.2.7/tests/test_threading.py +558 -0
  50. {cypari2-2.2.4 → cypari2-2.2.7}/uv.lock +58 -125
  51. cypari2-2.2.4/.github/workflows/dist.yml +0 -86
  52. cypari2-2.2.4/VERSION +0 -1
  53. cypari2-2.2.4/cypari2/__init__.py +0 -6
  54. {cypari2-2.2.4 → cypari2-2.2.7}/.cruft.json +0 -0
  55. {cypari2-2.2.4 → cypari2-2.2.7}/.gitignore +0 -0
  56. {cypari2-2.2.4 → cypari2-2.2.7}/CODE_OF_CONDUCT.md +0 -0
  57. {cypari2-2.2.4 → cypari2-2.2.7}/CONTRIBUTING.md +0 -0
  58. {cypari2-2.2.4 → cypari2-2.2.7}/LICENSE +0 -0
  59. {cypari2-2.2.4 → cypari2-2.2.7}/autogen/__init__.py +0 -0
  60. {cypari2-2.2.4 → cypari2-2.2.7}/autogen/parser.py +0 -0
  61. {cypari2-2.2.4 → cypari2-2.2.7}/autogen/ret.py +0 -0
  62. {cypari2-2.2.4 → cypari2-2.2.7}/cypari2/.gitignore +0 -0
  63. {cypari2-2.2.4 → cypari2-2.2.7}/cypari2/closure.pxd +0 -0
  64. {cypari2-2.2.4 → cypari2-2.2.7}/cypari2/convert.pxd +0 -0
  65. /cypari2-2.2.4/cypari2/cypari2.py.in → /cypari2-2.2.7/cypari2/cypari2.pc.in +0 -0
  66. {cypari2-2.2.4 → cypari2-2.2.7}/cypari2/gen.pxd +0 -0
  67. {cypari2-2.2.4 → cypari2-2.2.7}/cypari2/handle_error.pxd +0 -0
  68. {cypari2-2.2.4 → cypari2-2.2.7}/cypari2/paripriv.pxd +0 -0
  69. {cypari2-2.2.4 → cypari2-2.2.7}/cypari2/pycore_long.h +0 -0
  70. {cypari2-2.2.4 → cypari2-2.2.7}/cypari2/pycore_long.pxd +0 -0
  71. {cypari2-2.2.4 → cypari2-2.2.7}/cypari2/string_utils.pxd +0 -0
  72. {cypari2-2.2.4 → cypari2-2.2.7}/cypari2/string_utils.pyx +0 -0
  73. {cypari2-2.2.4 → cypari2-2.2.7}/docs/Makefile +0 -0
  74. {cypari2-2.2.4 → cypari2-2.2.7}/docs/source/closure.rst +0 -0
  75. {cypari2-2.2.4 → cypari2-2.2.7}/docs/source/convert.rst +0 -0
  76. {cypari2-2.2.4 → cypari2-2.2.7}/docs/source/gen.rst +0 -0
  77. {cypari2-2.2.4 → cypari2-2.2.7}/docs/source/handle_error.rst +0 -0
  78. {cypari2-2.2.4 → cypari2-2.2.7}/docs/source/pari_instance.rst +0 -0
  79. {cypari2-2.2.4 → cypari2-2.2.7}/docs/source/stack.rst +0 -0
  80. {cypari2-2.2.4 → cypari2-2.2.7}/readthedocs-conda.yml +0 -0
  81. {cypari2-2.2.4 → cypari2-2.2.7}/readthedocs.yml +0 -0
  82. {cypari2-2.2.4 → cypari2-2.2.7}/tests/meson.build +0 -0
  83. {cypari2-2.2.4 → cypari2-2.2.7}/tests/pari.desc +0 -0
  84. {cypari2-2.2.4 → cypari2-2.2.7}/tests/test.c +0 -0
  85. {cypari2-2.2.4 → cypari2-2.2.7}/tests/test_integers.py +0 -0
@@ -0,0 +1,80 @@
1
+ """Reject incomplete release sets and unsupported tags before uploading files."""
2
+
3
+ from email.parser import BytesParser
4
+ import os
5
+ from pathlib import Path
6
+ import re
7
+ import sys
8
+ import tarfile
9
+ import urllib.error
10
+ import urllib.request
11
+ import zipfile
12
+
13
+
14
+ def check(directory):
15
+ sources = list(directory.glob("*.tar.gz"))
16
+ if len(sources) != 1:
17
+ raise ValueError("Expected exactly one source distribution")
18
+ with tarfile.open(sources[0]) as source:
19
+ metadata_files = [m for m in source.getmembers() if m.name.count("/") == 1 and m.name.endswith("/PKG-INFO")]
20
+ if len(metadata_files) != 1:
21
+ raise ValueError("Expected one top-level sdist PKG-INFO")
22
+ metadata = BytesParser().parsebytes(source.extractfile(metadata_files[0]).read())
23
+ version = metadata["Version"]
24
+ if metadata["Name"] != "cypari2":
25
+ raise ValueError("Unexpected sdist project")
26
+ seen = set()
27
+ for wheel in directory.glob("*.whl"):
28
+ fields = wheel.name[:-4].split("-")
29
+ if len(fields) != 5 or fields[:2] != ["cypari2", version]:
30
+ raise ValueError(f"Unexpected wheel name/version: {wheel.name}")
31
+ _, _, python, abi, platforms = fields
32
+ if python not in {"cp313", "cp314", "cp315"} or abi != python:
33
+ raise ValueError(f"Unexpected interpreter tag: {wheel.name}")
34
+ for tag in platforms.split("."):
35
+ match = re.fullmatch(r"macosx_15_0_(arm64|x86_64)", tag)
36
+ if match:
37
+ family = "macosx", match[1]
38
+ else:
39
+ match = re.fullmatch(r"(manylinux|musllinux)(?:_\d+_\d+|2014|2010|1)_(aarch64|x86_64)", tag)
40
+ if not match:
41
+ raise ValueError(f"Unsupported wheel platform: {tag}")
42
+ family = match[1], match[2]
43
+ seen.add((python, *family))
44
+ with zipfile.ZipFile(wheel) as archive:
45
+ meta_files = [name for name in archive.namelist() if name.endswith(".dist-info/METADATA")]
46
+ if len(meta_files) != 1:
47
+ raise ValueError(f"Missing or ambiguous metadata: {wheel.name}")
48
+ wheel_meta = BytesParser().parsebytes(archive.read(meta_files[0]))
49
+ if wheel_meta["Name"] != "cypari2" or wheel_meta["Version"] != version:
50
+ raise ValueError(f"Inconsistent wheel metadata: {wheel.name}")
51
+ expected = {
52
+ (python, system, arch)
53
+ for python in ("cp313", "cp314", "cp315")
54
+ for system, arch in (("macosx", "arm64"), ("macosx", "x86_64"),
55
+ ("manylinux", "aarch64"), ("manylinux", "x86_64"),
56
+ ("musllinux", "aarch64"), ("musllinux", "x86_64"))
57
+ }
58
+ if seen != expected:
59
+ raise ValueError(f"Incomplete wheel matrix: missing={expected - seen}, extra={seen - expected}")
60
+ if set(directory.iterdir()) != set(sources) | set(directory.glob("*.whl")):
61
+ raise ValueError("Unexpected files in the release directory")
62
+ return version
63
+
64
+
65
+ if __name__ == "__main__":
66
+ version = check(Path(sys.argv[1]))
67
+ # PyPI uploads are per-file, not transactional. Check all files and refuse
68
+ # an existing version before the publisher can create a partial release.
69
+ if os.environ.get("GITHUB_EVENT_NAME") == "push" and os.environ.get("GITHUB_REF", "").startswith("refs/tags/"):
70
+ if os.environ["GITHUB_REF_NAME"].removeprefix("v") != version:
71
+ raise SystemExit("Release tag and package version disagree")
72
+ try:
73
+ with urllib.request.urlopen(f"https://pypi.org/pypi/cypari2/{version}/json", timeout=30) as response:
74
+ response.read()
75
+ except urllib.error.HTTPError as error:
76
+ if error.code != 404:
77
+ raise
78
+ else:
79
+ raise SystemExit(f"PyPI version {version} already exists; choose a new release version")
80
+ print(f"Complete distribution set verified for cypari2 {version}")
@@ -0,0 +1,45 @@
1
+ """Check the installed package and the origin of the loaded PARI library."""
2
+
3
+ import argparse
4
+ import ctypes
5
+ import json
6
+ import os
7
+ from pathlib import Path
8
+ import platform
9
+ import sys
10
+
11
+ import cypari2
12
+
13
+
14
+ parser = argparse.ArgumentParser(description=__doc__)
15
+ parser.add_argument("--bundled", action="store_true", help="require PARI from the installed wheel")
16
+ args = parser.parse_args()
17
+ prefix = Path(sys.prefix).resolve() if args.bundled else Path(os.environ["PARI_PREFIX"]).resolve()
18
+ module = Path(cypari2.__file__).resolve()
19
+ if sys.prefix == sys.base_prefix or not module.is_relative_to(Path(sys.prefix).resolve()):
20
+ raise SystemExit(f"cypari2 is not installed in the fresh venv: {module}")
21
+ pari = cypari2.Pari()
22
+ version = tuple(int(component) for component in pari.version())
23
+ if version[:3] != (2, 19, 1):
24
+ raise SystemExit(f"Unexpected PARI runtime version: {version}")
25
+ if platform.system() == "Linux":
26
+ libraries = {
27
+ Path(line.split()[-1]).resolve()
28
+ for line in Path("/proc/self/maps").read_text().splitlines()
29
+ if "/libpari" in line
30
+ }
31
+ else:
32
+ dyld = ctypes.CDLL(None)
33
+ dyld._dyld_image_count.restype = ctypes.c_uint32
34
+ dyld._dyld_get_image_name.argtypes = [ctypes.c_uint32]
35
+ dyld._dyld_get_image_name.restype = ctypes.c_char_p
36
+ libraries = {
37
+ Path(name.decode()).resolve()
38
+ for index in range(dyld._dyld_image_count())
39
+ if (name := dyld._dyld_get_image_name(index)) and b"/libpari" in name
40
+ }
41
+ if not libraries or any(not path.is_relative_to(prefix) for path in libraries):
42
+ raise SystemExit(f"Unexpected loaded PARI libraries: {libraries}")
43
+ print(json.dumps({"mode": "bundled" if args.bundled else "prefix",
44
+ "python": sys.version, "module": str(module),
45
+ "pari_version": version, "pari_libraries": sorted(map(str, libraries))}, indent=2))
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env bash
2
+ # Select the core PARI keg without changing which Python the matrix uses.
3
+ set -euo pipefail
4
+
5
+ if ! command -v brew >/dev/null && [[ -x /home/linuxbrew/.linuxbrew/bin/brew ]]; then
6
+ export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"
7
+ fi
8
+ expected_version=${PARI_VERSION:-2.19.1}
9
+ # Update brew itself and every configured tap, including on persistent runners.
10
+ brew update
11
+ pari_prefix=$(brew --prefix homebrew/core/pari)
12
+ receipt="$pari_prefix/INSTALL_RECEIPT.json"
13
+ if [[ -f $receipt ]] && ! jq -e '.source.tap == "homebrew/core"' "$receipt" >/dev/null; then
14
+ # Homebrew uses reinstall when switching an existing formula between taps.
15
+ brew reinstall homebrew/core/pari
16
+ elif [[ -x $pari_prefix/bin/gp && $("$pari_prefix/bin/gp" --version-short) != "$expected_version" ]]; then
17
+ brew upgrade homebrew/core/pari
18
+ else
19
+ brew install homebrew/core/pari
20
+ fi
21
+ gmp_prefix=$(brew --prefix --installed homebrew/core/gmp)
22
+ # A tap can install a keg with the same name and version on a shared runner.
23
+ if ! jq -e '.source.tap == "homebrew/core"' "$pari_prefix/INSTALL_RECEIPT.json" >/dev/null; then
24
+ echo "Expected a homebrew/core/pari keg at $pari_prefix" >&2
25
+ exit 1
26
+ fi
27
+ version=$("$pari_prefix/bin/gp" --version-short)
28
+ if [[ $version != "$expected_version" ]]; then
29
+ echo "Expected PARI $expected_version from Homebrew core, found $version in $pari_prefix" >&2
30
+ exit 1
31
+ fi
32
+ # cibuildwheel also runs this hook outside GitHub Actions.
33
+ if [[ -z ${GITHUB_ENV:-} || -z ${GITHUB_PATH:-} ]]; then
34
+ exit 0
35
+ fi
36
+ echo "$pari_prefix/bin" >> "$GITHUB_PATH"
37
+ {
38
+ echo "PARI_PREFIX=$pari_prefix"
39
+ echo "GMP_PREFIX=$gmp_prefix"
40
+ echo "LDFLAGS=-Wl,-rpath,$pari_prefix/lib"
41
+ echo "PKG_CONFIG_PATH=$gmp_prefix/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
42
+ if [[ $(uname -s) == Darwin ]]; then
43
+ echo "SDKROOT=$(xcrun --sdk macosx --show-sdk-path)"
44
+ fi
45
+ } >> "$GITHUB_ENV"
@@ -0,0 +1,74 @@
1
+ """Offline regressions for failures that must precede any PyPI upload."""
2
+
3
+ import hashlib
4
+ import importlib.util
5
+ import io
6
+ from pathlib import Path
7
+ import subprocess
8
+ import sys
9
+ import tarfile
10
+ import tempfile
11
+ import unittest
12
+ import zipfile
13
+
14
+
15
+ HERE = Path(__file__).resolve().parent
16
+ SPEC = importlib.util.spec_from_file_location("check_distributions", HERE / "check-distributions.py")
17
+ CHECKS = importlib.util.module_from_spec(SPEC)
18
+ SPEC.loader.exec_module(CHECKS)
19
+
20
+
21
+ class DistributionChecks(unittest.TestCase):
22
+ def setUp(self):
23
+ self.temp = tempfile.TemporaryDirectory()
24
+ self.addCleanup(self.temp.cleanup)
25
+ self.dist = Path(self.temp.name)
26
+ self.source = self.dist / "cypari2-2.2.7.tar.gz"
27
+ with tarfile.open(self.source, "w:gz") as archive:
28
+ content = b"Name: cypari2\nVersion: 2.2.7\n"
29
+ info = tarfile.TarInfo("cypari2-2.2.7/PKG-INFO")
30
+ info.size = len(content)
31
+ archive.addfile(info, io.BytesIO(content))
32
+ for python in ("cp313", "cp314", "cp315"):
33
+ for platform in ("macosx_15_0_arm64", "macosx_15_0_x86_64",
34
+ "manylinux_2_28_aarch64", "manylinux_2_28_x86_64",
35
+ "musllinux_1_2_aarch64", "musllinux_1_2_x86_64"):
36
+ self.wheel(python, platform)
37
+
38
+ def wheel(self, python, platform, version="2.2.7"):
39
+ path = self.dist / f"cypari2-2.2.7-{python}-{python}-{platform}.whl"
40
+ with zipfile.ZipFile(path, "w") as archive:
41
+ archive.writestr("cypari2-2.2.7.dist-info/METADATA", f"Name: cypari2\nVersion: {version}\n")
42
+ return path
43
+
44
+ def test_complete_set(self):
45
+ self.assertEqual(CHECKS.check(self.dist), "2.2.7")
46
+
47
+ def test_rejects_original_darwin_27_failure(self):
48
+ self.wheel("cp313", "macosx_27_0_arm64")
49
+ with self.assertRaisesRegex(ValueError, "Unsupported wheel platform"):
50
+ CHECKS.check(self.dist)
51
+
52
+ def test_missing_platform_fails_before_publish(self):
53
+ self.wheel("cp315", "musllinux_1_2_aarch64").unlink()
54
+ with self.assertRaisesRegex(ValueError, "Incomplete wheel matrix"):
55
+ CHECKS.check(self.dist)
56
+
57
+ def test_mixed_metadata_fails(self):
58
+ self.wheel("cp314", "macosx_15_0_arm64", version="2.2.6")
59
+ with self.assertRaisesRegex(ValueError, "Inconsistent wheel metadata"):
60
+ CHECKS.check(self.dist)
61
+
62
+ def test_changed_source_archive_fails(self):
63
+ digest = hashlib.sha256(self.source.read_bytes()).hexdigest()
64
+ command = [sys.executable, str(HERE / "verify-sdist.py"), str(self.dist), "--sha256", digest]
65
+ subprocess.run(command, check=True, capture_output=True)
66
+ with self.source.open("ab") as archive:
67
+ archive.write(b"changed")
68
+ result = subprocess.run(command, capture_output=True, text=True)
69
+ self.assertNotEqual(result.returncode, 0)
70
+ self.assertIn("checksum mismatch", result.stderr)
71
+
72
+
73
+ if __name__ == "__main__":
74
+ unittest.main()
@@ -0,0 +1,35 @@
1
+ """Record or verify the one source archive shared by distribution jobs."""
2
+
3
+ import argparse
4
+ import hashlib
5
+ from pathlib import Path
6
+ import tarfile
7
+
8
+
9
+ def main():
10
+ parser = argparse.ArgumentParser(description=__doc__)
11
+ parser.add_argument("directory", type=Path)
12
+ parser.add_argument("--sha256")
13
+ parser.add_argument("--extract", type=Path)
14
+ args = parser.parse_args()
15
+ archives = list(args.directory.glob("*.tar.gz"))
16
+ if len(archives) != 1:
17
+ raise SystemExit(f"Expected one sdist, found {archives}")
18
+ archive = archives[0]
19
+ digest = hashlib.sha256(archive.read_bytes()).hexdigest()
20
+ if args.sha256 is not None and digest != args.sha256:
21
+ raise SystemExit(f"Source archive checksum mismatch: {digest}")
22
+ if args.extract:
23
+ args.extract.mkdir(exist_ok=False)
24
+ with tarfile.open(archive) as source:
25
+ source.extractall(args.extract, filter="data")
26
+ roots = list(args.extract.iterdir())
27
+ if len(roots) != 1 or not (roots[0] / "Makefile").is_file():
28
+ raise SystemExit("The sdist does not contain one complete test source tree")
29
+ print(f"source={roots[0]}")
30
+ print(f"filename={archive.name}")
31
+ print(f"sha256={digest}")
32
+
33
+
34
+ if __name__ == "__main__":
35
+ main()
@@ -0,0 +1,210 @@
1
+ name: Distribution
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+ workflow_dispatch:
7
+ inputs:
8
+ source-ref:
9
+ description: Optional source ref to validate (manual runs never publish)
10
+ required: false
11
+ type: string
12
+ c-standard:
13
+ description: Optional GNU17 override for historical sources (empty uses the source default)
14
+ required: false
15
+ default: ''
16
+ type: string
17
+
18
+ concurrency:
19
+ group: ${{ github.workflow }}-${{ github.ref }}
20
+ cancel-in-progress: true
21
+
22
+ env:
23
+ PARI_VERSION: '2.19.1'
24
+ PARI_INSTALL_DEPENDENCIES: '1'
25
+ C_STANDARD: ${{ inputs.c-standard || '' }}
26
+
27
+ jobs:
28
+ make_sdist:
29
+ name: Build the source distribution
30
+ runs-on: ubuntu-latest
31
+ outputs:
32
+ sha256: ${{ steps.sdist.outputs.sha256 }}
33
+ filename: ${{ steps.sdist.outputs.filename }}
34
+ steps:
35
+ - uses: actions/checkout@v7
36
+ - uses: actions/checkout@v7
37
+ with:
38
+ ref: ${{ inputs.source-ref || github.sha }}
39
+ path: source
40
+ - uses: actions/setup-python@v7
41
+ with:
42
+ python-version: '3.14'
43
+ - uses: astral-sh/setup-uv@v10.4.0
44
+ - name: Set up Homebrew core PARI
45
+ run: bash .github/setup-brew-pari.sh
46
+ - name: Build sdist once
47
+ id: sdist
48
+ run: |
49
+ case "$C_STANDARD" in
50
+ ''|gnu17) ;;
51
+ *) echo "Unsupported historical C standard override: $C_STANDARD" >&2; exit 1 ;;
52
+ esac
53
+ git -C source rev-parse HEAD
54
+ config_args=(--config-setting "setup-args=-Dpari_prefix=$PARI_PREFIX")
55
+ if [ -n "$C_STANDARD" ]; then
56
+ echo "Historical C standard override: $C_STANDARD"
57
+ config_args+=(--config-setting "setup-args=-Dc_std=$C_STANDARD")
58
+ fi
59
+ uv build --sdist source --out-dir dist "${config_args[@]}"
60
+ python .github/verify-sdist.py dist >> "$GITHUB_OUTPUT"
61
+ - uses: actions/upload-artifact@v7
62
+ with:
63
+ path: dist/*.tar.gz
64
+ name: release-sdist
65
+ if-no-files-found: error
66
+
67
+ test_sdist_arm:
68
+ name: Test sdist (${{ matrix.os }}, Python ${{ matrix.python }})
69
+ needs: make_sdist
70
+ runs-on: ${{ matrix.os }}
71
+ strategy:
72
+ fail-fast: false
73
+ matrix:
74
+ os: [ubuntu-24.04-arm, macos-15]
75
+ python: ['3.13', '3.14', '3.15']
76
+ env:
77
+ SDIST_SHA256: ${{ needs.make_sdist.outputs.sha256 }}
78
+ steps:
79
+ - uses: actions/checkout@v7
80
+ - uses: actions/setup-python@v7
81
+ with:
82
+ python-version: ${{ matrix.python }}
83
+ - uses: astral-sh/setup-uv@v10.4.0
84
+ - uses: actions/download-artifact@v8
85
+ with:
86
+ name: release-sdist
87
+ path: dist
88
+ - name: Verify the shared sdist
89
+ run: python .github/verify-sdist.py dist --sha256 "$SDIST_SHA256" --extract sdist-tests
90
+ - name: Set up Homebrew core PARI
91
+ run: bash .github/setup-brew-pari.sh
92
+ - name: Install the sdist into a fresh noneditable environment
93
+ run: |
94
+ config_args=(--config-settings-package "cypari2:setup-args=-Dpari_prefix=$PARI_PREFIX")
95
+ if [ -n "$C_STANDARD" ]; then
96
+ config_args+=(--config-settings-package "cypari2:setup-args=-Dc_std=$C_STANDARD")
97
+ fi
98
+ uv venv --python python .venv
99
+ uv pip install --python .venv/bin/python "${config_args[@]}" dist/*.tar.gz
100
+ uv pip check --python .venv/bin/python
101
+ .venv/bin/python -I .github/check-installed.py
102
+ .venv/bin/python -I -c "import sys; from pathlib import Path; sys.path.append(str(next(Path('sdist-tests').iterdir()).resolve())); import autogen.doc, autogen.generator, autogen.parser"
103
+ - name: Run the complete installed-package test suite
104
+ # Test scripts import subprocess_helpers from the extracted tests directory.
105
+ run: make -C sdist-tests/* check PYTHON="$PWD/.venv/bin/python -E -s"
106
+
107
+ build_wheels:
108
+ name: Build wheels on ${{ matrix.os }}
109
+ needs: make_sdist
110
+ runs-on: ${{ matrix.os }}
111
+ strategy:
112
+ fail-fast: false
113
+ matrix:
114
+ # macOS 15 keeps GMP and the repaired wheels compatible with macOS 15.
115
+ os: [ubuntu-latest, ubuntu-24.04-arm, macos-15-intel, macos-15]
116
+ steps:
117
+ - uses: actions/checkout@v7
118
+ - uses: actions/setup-python@v7
119
+ with:
120
+ python-version: '3.14'
121
+ - uses: astral-sh/setup-uv@v10.4.0
122
+ - uses: actions/download-artifact@v8
123
+ with:
124
+ name: release-sdist
125
+ path: dist
126
+ - name: Verify the shared sdist
127
+ id: verified
128
+ env:
129
+ SDIST_SHA256: ${{ needs.make_sdist.outputs.sha256 }}
130
+ run: python .github/verify-sdist.py dist --sha256 "$SDIST_SHA256" --extract wheel-source >> "$GITHUB_OUTPUT"
131
+ - name: Select the PARI prefix and optional C standard for wheel builds
132
+ if: runner.os == 'macOS' || inputs.c-standard
133
+ run: |
134
+ pari_prefix=/tmp/cypari2-pari
135
+ if [ "$RUNNER_OS" = macOS ]; then
136
+ pari_prefix=$(brew --prefix homebrew/core/pari)
137
+ fi
138
+ config_args=("setup-args=-Dpari_prefix=$pari_prefix")
139
+ if [ -n "$C_STANDARD" ]; then
140
+ config_args+=("setup-args=-Dc_std=$C_STANDARD")
141
+ fi
142
+ printf 'CIBW_CONFIG_SETTINGS=%s\n' "${config_args[*]}" >> "$GITHUB_ENV"
143
+ - name: Build and test wheels from that sdist
144
+ uses: pypa/cibuildwheel@v4.3.5
145
+ with:
146
+ package-dir: ${{ steps.verified.outputs.source }}
147
+ config-file: pyproject.toml
148
+ env:
149
+ # Keep the extracted sdist unchanged, even for an older source ref.
150
+ CIBW_TEST_SOURCES: >-
151
+ ${{ steps.verified.outputs.source }}/tests
152
+ ${{ steps.verified.outputs.source }}/autogen
153
+ ${{ steps.verified.outputs.source }}/Makefile
154
+ ${{ steps.verified.outputs.source }}/pyproject.toml
155
+ CIBW_TEST_COMMAND: >-
156
+ python {project}/.github/check-installed.py --bundled &&
157
+ cd ${{ steps.verified.outputs.source }} &&
158
+ python -c "import autogen.doc, autogen.generator, autogen.parser; from cypari2 import Pari; assert tuple(map(int, Pari().version()))[:3] == (2, 19, 1)" && make check
159
+ MACOSX_DEPLOYMENT_TARGET: '15.0'
160
+ - uses: actions/upload-artifact@v7
161
+ with:
162
+ name: release-wheels-${{ matrix.os }}
163
+ path: wheelhouse/*.whl
164
+ if-no-files-found: error
165
+
166
+ check_distributions:
167
+ name: Check every release file before any upload
168
+ needs: [make_sdist, test_sdist_arm, build_wheels]
169
+ runs-on: ubuntu-latest
170
+ steps:
171
+ - uses: actions/checkout@v7
172
+ - uses: actions/setup-python@v7
173
+ with:
174
+ python-version: '3.14'
175
+ - uses: astral-sh/setup-uv@v10.4.0
176
+ - uses: actions/download-artifact@v8
177
+ with:
178
+ pattern: release-*
179
+ path: dist
180
+ merge-multiple: true
181
+ - name: Check metadata, source hash and supported wheel platforms
182
+ env:
183
+ SDIST_SHA256: ${{ needs.make_sdist.outputs.sha256 }}
184
+ run: |
185
+ python .github/test_distribution_checks.py
186
+ python .github/verify-sdist.py dist --sha256 "$SDIST_SHA256"
187
+ python .github/check-distributions.py dist
188
+ uvx twine check --strict dist/*
189
+
190
+ pypi-publish:
191
+ name: Publish the tested distributions
192
+ needs: check_distributions
193
+ if: github.repository == 'sagemath/cypari2' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
194
+ runs-on: ubuntu-latest
195
+ permissions:
196
+ id-token: write
197
+ attestations: write
198
+ contents: read
199
+ steps:
200
+ - uses: actions/download-artifact@v8
201
+ with:
202
+ pattern: release-*
203
+ path: dist
204
+ merge-multiple: true
205
+ - uses: actions/attest@v4
206
+ with:
207
+ subject-path: dist/*
208
+ - uses: pypa/gh-action-pypi-publish@release/v1
209
+ with:
210
+ verbose: true
@@ -21,18 +21,27 @@ jobs:
21
21
  fail-fast: false
22
22
  matrix:
23
23
  os: [ubuntu-latest]
24
- python-version: ['3.12', '3.13', '3.14']
25
- pari-version: ['2.15.4', '2.15.5', '2.17.2']
24
+ python-version: ['3.13', '3.14', '3.15']
25
+ pari-version: ['2.17.4', '2.19.1']
26
26
  include:
27
- - os: macos-latest
28
- python-version: '3.12'
29
- pari-version: '2.17.2' # Whatever comes with homebrew
30
- - os: macos-latest
27
+ - os: macos-15
31
28
  python-version: '3.13'
32
- pari-version: '2.17.2' # Whatever comes with homebrew
33
- - os: macos-latest
29
+ pari-version: '2.19.1'
30
+ - os: macos-15
34
31
  python-version: '3.14'
35
- pari-version: '2.17.2' # Whatever comes with homebrew
32
+ pari-version: '2.19.1'
33
+ - os: macos-15
34
+ python-version: '3.15'
35
+ pari-version: '2.19.1'
36
+ - os: darwin-27
37
+ python-version: '3.13'
38
+ pari-version: '2.19.1'
39
+ - os: darwin-27
40
+ python-version: '3.14'
41
+ pari-version: '2.19.1'
42
+ - os: darwin-27
43
+ python-version: '3.15'
44
+ pari-version: '2.19.1'
36
45
  env:
37
46
  LC_ALL: C
38
47
  PARI_VERSION: ${{ matrix.pari-version }}
@@ -41,7 +50,7 @@ jobs:
41
50
  shell: ${{ matrix.os == 'windows-latest' && 'msys2 {0}' || 'bash' }}
42
51
  steps:
43
52
  - name: Set up the repository
44
- uses: actions/checkout@v4
53
+ uses: actions/checkout@v7
45
54
  - name: Setup MSYS2
46
55
  if: runner.os == 'Windows'
47
56
  id: msys2
@@ -66,24 +75,23 @@ jobs:
66
75
  path-type: inherit
67
76
  - name: Set up Python ${{ matrix.python-version }}
68
77
  if: runner.os != 'Windows'
69
- uses: actions/setup-python@v4
78
+ uses: actions/setup-python@v7
70
79
  with:
71
80
  python-version: ${{ matrix.python-version }}
72
- - name: Install PARI
73
- if: matrix.os != 'macos-latest'
74
- run: |
75
- bash -x .install-pari.sh
76
- - name: Install PARI
77
- if: matrix.os == 'macos-latest'
78
- run: |
79
- brew install pari
81
+ allow-prereleases: true
82
+ - name: Set up Homebrew core PARI
83
+ if: runner.os != 'Windows' && matrix.pari-version == '2.19.1'
84
+ run: bash .github/setup-brew-pari.sh
85
+ - name: Install PARI from source
86
+ if: runner.os == 'Windows' || matrix.pari-version != '2.19.1'
87
+ run: bash -x .install-pari.sh
80
88
  - name: Smoke test PARI
81
89
  run: |
82
- if [ ${{ runner.os }} = macOS ]; then
83
- HOMEBREW=`brew --prefix`
84
- clang -v tests/test.c -o test -I$HOMEBREW/include -L$HOMEBREW/lib -lpari -lgmp
90
+ if [ -n "${PARI_PREFIX:-}" ]; then
91
+ cc -v tests/test.c -o test -I"$PARI_PREFIX/include" -L"$PARI_PREFIX/lib" \
92
+ -I"$GMP_PREFIX/include" -L"$GMP_PREFIX/lib" -Wl,-rpath,"$PARI_PREFIX/lib" -lpari -lgmp
85
93
  else
86
- gcc -v tests/test.c -o test -I/usr/local/include -L/usr/local/bin -lpari -lgmp
94
+ gcc -v tests/test.c -o test -I/usr/include -L/usr/lib -lpari -lgmp
87
95
  fi
88
96
  expected="zeta(2) = 1.6449340668482264364
89
97
  p = x^3 + x^2 + x - 1
@@ -101,7 +109,7 @@ jobs:
101
109
  fi
102
110
 
103
111
  - name: Setup uv
104
- uses: astral-sh/setup-uv@v6
112
+ uses: astral-sh/setup-uv@v10.4.0
105
113
 
106
114
  - name: Build
107
115
  run: |
@@ -112,12 +120,23 @@ jobs:
112
120
  echo $PATH
113
121
  echo $C_INCLUDE_PATH
114
122
  echo $LIBRARY_PATH
123
+ config_args=(--config-settings-package cypari2:builddir=builddir)
124
+ if [ -n "${PARI_PREFIX:-}" ]; then
125
+ config_args+=(--config-settings-package "cypari2:setup-args=-Dpari_prefix=$PARI_PREFIX")
126
+ fi
115
127
  uv sync --frozen --inexact -v --no-install-project
116
- uv sync --frozen --inexact -v --no-build-isolation --no-editable --config-settings=builddir=builddir
128
+ uv sync --frozen --inexact -v --no-build-isolation --no-editable --reinstall-package cypari2 "${config_args[@]}"
117
129
  - name: Test
118
130
  run: |
119
- uv run make check
131
+ if [ -n "${PARI_PREFIX:-}" ]; then
132
+ uv run --no-sync python -I .github/check-installed.py
133
+ fi
134
+ uv run --no-sync make check
120
135
  - name: Build docs
121
136
  run: |
122
- uv sync --frozen --inexact -v --group doc
123
- (cd docs && uv run make html)
137
+ config_args=(--config-settings-package cypari2:builddir=builddir)
138
+ if [ -n "${PARI_PREFIX:-}" ]; then
139
+ config_args+=(--config-settings-package "cypari2:setup-args=-Dpari_prefix=$PARI_PREFIX")
140
+ fi
141
+ uv sync --frozen --inexact -v --no-build-isolation-package cypari2 --no-editable "${config_args[@]}" --group doc
142
+ (cd docs && uv run --no-sync make html)