multiloop 0.1.3__tar.gz → 0.1.4__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 (121) hide show
  1. multiloop-0.1.4/.github/actions/build-dist/action.yml +78 -0
  2. multiloop-0.1.4/.github/actions/run-lint/action.yml +44 -0
  3. multiloop-0.1.4/.github/actions/setup-env/action.yml +66 -0
  4. {multiloop-0.1.3 → multiloop-0.1.4}/.github/dependabot.yml +10 -0
  5. {multiloop-0.1.3 → multiloop-0.1.4}/.github/pull_request_template.md +5 -8
  6. multiloop-0.1.4/.github/scripts/_common.py +120 -0
  7. multiloop-0.1.4/.github/scripts/build_host_wheels.py +48 -0
  8. multiloop-0.1.4/.github/scripts/check_release.py +105 -0
  9. multiloop-0.1.4/.github/scripts/run_ci_versions.py +66 -0
  10. multiloop-0.1.4/.github/scripts/run_rust_tests.py +54 -0
  11. multiloop-0.1.4/.github/scripts/verify_dist.py +91 -0
  12. multiloop-0.1.4/.github/workflows/ci.yml +124 -0
  13. multiloop-0.1.4/.github/workflows/publish.yml +223 -0
  14. {multiloop-0.1.3 → multiloop-0.1.4}/.github/workflows/release-drafter.yml +3 -4
  15. {multiloop-0.1.3 → multiloop-0.1.4}/.gitignore +1 -0
  16. {multiloop-0.1.3 → multiloop-0.1.4}/.pre-commit-config.yaml +5 -5
  17. multiloop-0.1.4/AGENTS.md +412 -0
  18. {multiloop-0.1.3 → multiloop-0.1.4}/CHANGELOG.md +14 -0
  19. {multiloop-0.1.3 → multiloop-0.1.4}/CITATION.cff +2 -2
  20. multiloop-0.1.4/CONTRIBUTING.md +201 -0
  21. {multiloop-0.1.3 → multiloop-0.1.4}/Cargo.lock +1 -1
  22. {multiloop-0.1.3 → multiloop-0.1.4}/Cargo.toml +1 -1
  23. multiloop-0.1.4/Makefile +56 -0
  24. {multiloop-0.1.3 → multiloop-0.1.4}/PKG-INFO +9 -7
  25. {multiloop-0.1.3 → multiloop-0.1.4}/README.md +6 -6
  26. {multiloop-0.1.3 → multiloop-0.1.4}/README_ZH.md +6 -6
  27. {multiloop-0.1.3 → multiloop-0.1.4}/docs/API.md +78 -32
  28. {multiloop-0.1.3 → multiloop-0.1.4}/docs/API_ZH.md +88 -39
  29. {multiloop-0.1.3 → multiloop-0.1.4}/docs/CHOOSING.md +20 -16
  30. {multiloop-0.1.3 → multiloop-0.1.4}/docs/CHOOSING_ZH.md +18 -14
  31. multiloop-0.1.4/docs/CONCURRENCY.md +435 -0
  32. multiloop-0.1.4/docs/CONCURRENCY_ZH.md +383 -0
  33. {multiloop-0.1.3 → multiloop-0.1.4}/examples/03_taskgroup_timeout.py +5 -4
  34. {multiloop-0.1.3 → multiloop-0.1.4}/examples/README.md +1 -1
  35. {multiloop-0.1.3 → multiloop-0.1.4}/pyproject.toml +3 -1
  36. multiloop-0.1.4/src/cancel.rs +240 -0
  37. multiloop-0.1.4/src/channel.rs +1027 -0
  38. multiloop-0.1.4/src/errors.rs +62 -0
  39. multiloop-0.1.4/src/lib.rs +46 -0
  40. {multiloop-0.1.3 → multiloop-0.1.4}/src/metrics.rs +1 -1
  41. {multiloop-0.1.3 → multiloop-0.1.4}/src/multiloop/__init__.py +29 -6
  42. {multiloop-0.1.3 → multiloop-0.1.4}/src/multiloop/__init__.pyi +13 -7
  43. multiloop-0.1.4/src/multiloop/_cancel.py +481 -0
  44. {multiloop-0.1.3 → multiloop-0.1.4}/src/multiloop/_metrics.py +2 -0
  45. multiloop-0.1.4/src/multiloop/_multiloop_core.pyi +196 -0
  46. {multiloop-0.1.3 → multiloop-0.1.4}/src/multiloop/_sync.py +237 -360
  47. multiloop-0.1.4/src/multiloop/_taskgroup.py +901 -0
  48. {multiloop-0.1.3 → multiloop-0.1.4}/src/multiloop/context.py +32 -43
  49. {multiloop-0.1.3 → multiloop-0.1.4}/src/multiloop/exceptions.py +2 -22
  50. multiloop-0.1.4/src/multiloop/pool.py +838 -0
  51. {multiloop-0.1.3 → multiloop-0.1.4}/src/multiloop/primitives.py +215 -207
  52. multiloop-0.1.4/src/multiloop/rwlock.py +147 -0
  53. multiloop-0.1.4/src/pool.rs +488 -0
  54. multiloop-0.1.4/src/rwlock.rs +565 -0
  55. multiloop-0.1.4/src/sync.rs +1216 -0
  56. multiloop-0.1.4/src/tests.rs +925 -0
  57. multiloop-0.1.4/src/waiter.rs +262 -0
  58. multiloop-0.1.4/src/waitgroup.rs +148 -0
  59. multiloop-0.1.4/tests/test_cancel_scope.py +1304 -0
  60. {multiloop-0.1.3 → multiloop-0.1.4}/tests/test_channel.py +495 -218
  61. {multiloop-0.1.3 → multiloop-0.1.4}/tests/test_docs.py +4 -3
  62. multiloop-0.1.4/tests/test_ffi_gc_safety.py +557 -0
  63. {multiloop-0.1.3 → multiloop-0.1.4}/tests/test_free_threading.py +15 -9
  64. multiloop-0.1.4/tests/test_go_parity.py +682 -0
  65. {multiloop-0.1.3 → multiloop-0.1.4}/tests/test_pool.py +422 -102
  66. {multiloop-0.1.3 → multiloop-0.1.4}/tests/test_sync_condition_barrier.py +145 -44
  67. {multiloop-0.1.3 → multiloop-0.1.4}/tests/test_sync_lock_event.py +115 -129
  68. {multiloop-0.1.3 → multiloop-0.1.4}/tests/test_sync_primitives.py +59 -307
  69. {multiloop-0.1.3 → multiloop-0.1.4}/tests/test_taskgroup.py +256 -47
  70. {multiloop-0.1.3 → multiloop-0.1.4}/uv.lock +2 -2
  71. multiloop-0.1.3/.github/workflows/ci.yml +0 -218
  72. multiloop-0.1.3/.github/workflows/publish.yml +0 -264
  73. multiloop-0.1.3/AGENTS.md +0 -385
  74. multiloop-0.1.3/CONTRIBUTING.md +0 -211
  75. multiloop-0.1.3/Makefile +0 -42
  76. multiloop-0.1.3/docs/CONCURRENCY.md +0 -423
  77. multiloop-0.1.3/docs/CONCURRENCY_ZH.md +0 -372
  78. multiloop-0.1.3/src/channel.rs +0 -613
  79. multiloop-0.1.3/src/lib.rs +0 -633
  80. multiloop-0.1.3/src/multiloop/_cancel.py +0 -473
  81. multiloop-0.1.3/src/multiloop/_channel_base.py +0 -80
  82. multiloop-0.1.3/src/multiloop/_multiloop_core.pyi +0 -89
  83. multiloop-0.1.3/src/multiloop/_taskgroup.py +0 -594
  84. multiloop-0.1.3/src/multiloop/pool.py +0 -668
  85. multiloop-0.1.3/src/multiloop/rwlock.py +0 -269
  86. multiloop-0.1.3/src/pool.rs +0 -263
  87. multiloop-0.1.3/src/rwlock.rs +0 -273
  88. multiloop-0.1.3/src/waitgroup.rs +0 -115
  89. multiloop-0.1.3/tests/test_cancel_scope.py +0 -987
  90. multiloop-0.1.3/tests/test_go_parity.py +0 -274
  91. multiloop-0.1.3/tests/test_regression_bugs.py +0 -472
  92. {multiloop-0.1.3 → multiloop-0.1.4}/.editorconfig +0 -0
  93. {multiloop-0.1.3 → multiloop-0.1.4}/.github/FUNDING.yml +0 -0
  94. {multiloop-0.1.3 → multiloop-0.1.4}/.github/ISSUE_TEMPLATE/bug_report.yml +0 -0
  95. {multiloop-0.1.3 → multiloop-0.1.4}/.github/ISSUE_TEMPLATE/feature_request.yml +0 -0
  96. {multiloop-0.1.3 → multiloop-0.1.4}/.github/release-drafter.yml +0 -0
  97. {multiloop-0.1.3 → multiloop-0.1.4}/.python-version +0 -0
  98. {multiloop-0.1.3 → multiloop-0.1.4}/CODEOWNERS +0 -0
  99. {multiloop-0.1.3 → multiloop-0.1.4}/CODE_OF_CONDUCT.md +0 -0
  100. {multiloop-0.1.3 → multiloop-0.1.4}/LICENSE +0 -0
  101. {multiloop-0.1.3 → multiloop-0.1.4}/SECURITY.md +0 -0
  102. {multiloop-0.1.3 → multiloop-0.1.4}/benchmarks/bench_multithread_loops.py +0 -0
  103. {multiloop-0.1.3 → multiloop-0.1.4}/benchmarks/benchmark_pull_model.py +0 -0
  104. {multiloop-0.1.3 → multiloop-0.1.4}/build.rs +0 -0
  105. {multiloop-0.1.3 → multiloop-0.1.4}/deny.toml +0 -0
  106. {multiloop-0.1.3 → multiloop-0.1.4}/examples/00_pool_basics.py +0 -0
  107. {multiloop-0.1.3 → multiloop-0.1.4}/examples/01_channels_select.py +0 -0
  108. {multiloop-0.1.3 → multiloop-0.1.4}/examples/02_waitgroup_once.py +0 -0
  109. {multiloop-0.1.3 → multiloop-0.1.4}/examples/04_sync_primitives.py +0 -0
  110. {multiloop-0.1.3 → multiloop-0.1.4}/examples/05_multicore_pipeline.py +0 -0
  111. {multiloop-0.1.3 → multiloop-0.1.4}/examples/README_ZH.md +0 -0
  112. {multiloop-0.1.3 → multiloop-0.1.4}/rust-toolchain.toml +0 -0
  113. {multiloop-0.1.3 → multiloop-0.1.4}/src/multiloop/_logging.py +0 -0
  114. {multiloop-0.1.3 → multiloop-0.1.4}/src/multiloop/_options.py +0 -0
  115. {multiloop-0.1.3 → multiloop-0.1.4}/src/multiloop/_rust.py +0 -0
  116. {multiloop-0.1.3 → multiloop-0.1.4}/src/multiloop/py.typed +0 -0
  117. {multiloop-0.1.3 → multiloop-0.1.4}/src/multiloop/testing/__init__.py +0 -0
  118. {multiloop-0.1.3 → multiloop-0.1.4}/tests/conftest.py +0 -0
  119. {multiloop-0.1.3 → multiloop-0.1.4}/tests/test_logging.py +0 -0
  120. {multiloop-0.1.3 → multiloop-0.1.4}/tests/test_loop_factory.py +0 -0
  121. {multiloop-0.1.3 → multiloop-0.1.4}/tests/test_perf_regression.py +0 -0
@@ -0,0 +1,78 @@
1
+ name: "Build, Verify & Upload Distribution Artifacts"
2
+ description: "Build wheels (container or host) or sdist, run strict twine metadata check, and upload artifacts."
3
+
4
+ inputs:
5
+ mode:
6
+ description: "Build mode: container-wheels | host-wheels | sdist."
7
+ required: true
8
+ rust-target:
9
+ description: "Rust target triple for host wheel builds (e.g. x86_64-apple-darwin)."
10
+ required: false
11
+ default: ""
12
+ manylinux:
13
+ description: "Manylinux policy for Linux container wheel builds (e.g. 2_28)."
14
+ required: false
15
+ default: "2_28"
16
+ python-versions:
17
+ description: "Space-separated Python versions for wheels (e.g. '3.14t 3.15t')."
18
+ required: false
19
+ default: "3.14t 3.15t"
20
+ cache-key:
21
+ description: "Optional Rust cache key suffix for host wheel builds."
22
+ required: false
23
+ default: ""
24
+ artifact-name:
25
+ description: "Artifact name to upload."
26
+ required: true
27
+ maturin-version:
28
+ description: "Pinned maturin release matching uv.lock."
29
+ required: false
30
+ default: "v1.14.1"
31
+
32
+ runs:
33
+ using: "composite"
34
+ steps:
35
+ - name: Build sdist
36
+ if: ${{ inputs.mode == 'sdist' }}
37
+ uses: PyO3/maturin-action@v1
38
+ with:
39
+ command: sdist
40
+ maturin-version: ${{ inputs.maturin-version }}
41
+ args: --out dist
42
+ rust-toolchain: stable
43
+
44
+ - name: Build Linux wheels in manylinux container
45
+ if: ${{ inputs.mode == 'container-wheels' }}
46
+ uses: PyO3/maturin-action@v1
47
+ with:
48
+ maturin-version: ${{ inputs.maturin-version }}
49
+ manylinux: ${{ inputs.manylinux }}
50
+ args: --release --locked --out dist --interpreter ${{ inputs.python-versions }} --compatibility pypi
51
+
52
+ - name: Install Rust toolchain for host wheel builds
53
+ if: ${{ inputs.mode == 'host-wheels' }}
54
+ uses: dtolnay/rust-toolchain@stable
55
+ with:
56
+ targets: ${{ inputs.rust-target }}
57
+
58
+ - name: Restore Rust cache for host wheel builds
59
+ if: ${{ inputs.mode == 'host-wheels' }}
60
+ uses: Swatinem/rust-cache@v2
61
+ with:
62
+ key: dist-${{ inputs.cache-key }}
63
+
64
+ - name: Build host wheels across target Python versions
65
+ if: ${{ inputs.mode == 'host-wheels' }}
66
+ shell: bash
67
+ run: uv run --no-project python .github/scripts/build_host_wheels.py --target "${{ inputs.rust-target }}" --out dist ${{ inputs.python-versions }}
68
+
69
+ - name: Check distribution metadata
70
+ shell: bash
71
+ run: uvx twine check --strict dist/*
72
+
73
+ - name: Upload distribution artifacts
74
+ uses: actions/upload-artifact@v4
75
+ with:
76
+ name: ${{ inputs.artifact-name }}
77
+ path: dist
78
+ if-no-files-found: error
@@ -0,0 +1,44 @@
1
+ name: "Run Lint, Static Analysis & Packaging Checks"
2
+ description: "Execute Rust clippy/fmt/doc/deny, Python ruff/mypy/pyright, release metadata parity, and sdist twine validation."
3
+
4
+ runs:
5
+ using: "composite"
6
+ steps:
7
+ - name: Cargo Clippy & Format Check
8
+ shell: bash
9
+ run: |
10
+ cargo clippy --locked -- -D warnings
11
+ cargo fmt --check
12
+
13
+ - name: Python Static Analysis & Formatting
14
+ shell: bash
15
+ env:
16
+ MYPYPATH: src
17
+ run: |
18
+ uv run --no-sync ruff check .
19
+ uv run --no-sync ruff format --check .
20
+ uv run --no-sync mypy --strict src/multiloop
21
+ uv run --no-sync pyright src/multiloop
22
+
23
+ - name: Release Metadata Parity Check
24
+ shell: bash
25
+ run: uv run --no-sync python .github/scripts/check_release.py
26
+
27
+ - name: Cargo Deny Check
28
+ uses: EmbarkStudios/cargo-deny-action@v2
29
+ with:
30
+ command: check advisories
31
+
32
+ - name: Rustdoc Check
33
+ shell: bash
34
+ env:
35
+ RUSTDOCFLAGS: "-D warnings"
36
+ run: cargo doc --no-deps --document-private-items --locked
37
+
38
+ - name: Sdist Packaging & Metadata Check
39
+ shell: bash
40
+ run: |
41
+ rm -rf dist-check
42
+ uv run --no-sync maturin sdist --out dist-check
43
+ uvx twine check --strict dist-check/*
44
+ rm -rf dist-check
@@ -0,0 +1,66 @@
1
+ name: "Setup Toolchain & Python Environment"
2
+ description: "Configure Rust toolchain (with cache), uv, free-threaded Python, and locked dependencies."
3
+
4
+ inputs:
5
+ python-version:
6
+ description: "Target Python version for uv (e.g. 3.14t, 3.15t)."
7
+ required: false
8
+ default: "3.14t"
9
+ install-rust:
10
+ description: "Whether to install the stable Rust toolchain."
11
+ required: false
12
+ default: "true"
13
+ rust-components:
14
+ description: "Comma-separated Rustup components to install (e.g. 'clippy, rustfmt')."
15
+ required: false
16
+ default: ""
17
+ cache-rust:
18
+ description: "Whether to cache Cargo registry and target directory."
19
+ required: false
20
+ default: "true"
21
+ cache-key:
22
+ description: "Optional extra suffix for rust-cache key (useful in build matrices)."
23
+ required: false
24
+ default: ""
25
+ sync-mode:
26
+ description: "Dependency sync mode: no-project | project | none."
27
+ required: false
28
+ default: "no-project"
29
+ uv-cache:
30
+ description: "uv cache mode: auto | true | false."
31
+ required: false
32
+ default: "auto"
33
+
34
+ runs:
35
+ using: "composite"
36
+ steps:
37
+ - name: Install Rust toolchain
38
+ if: ${{ inputs.install-rust == 'true' }}
39
+ uses: dtolnay/rust-toolchain@stable
40
+ with:
41
+ components: ${{ inputs.rust-components }}
42
+
43
+ - name: Restore Rust cache
44
+ if: ${{ inputs.install-rust == 'true' && inputs.cache-rust == 'true' }}
45
+ uses: Swatinem/rust-cache@v2
46
+ with:
47
+ key: ${{ inputs.cache-key }}
48
+
49
+ - name: Set up uv and Python ${{ inputs.python-version }}
50
+ uses: astral-sh/setup-uv@v10.4.0
51
+ with:
52
+ enable-cache: ${{ inputs.uv-cache }}
53
+ cache-dependency-glob: |
54
+ uv.lock
55
+ pyproject.toml
56
+ python-version: ${{ inputs.python-version }}
57
+
58
+ - name: Sync dependencies (dev group only, skip local build)
59
+ if: ${{ inputs.sync-mode == 'no-project' }}
60
+ shell: bash
61
+ run: uv sync --locked --no-install-project --group dev
62
+
63
+ - name: Sync project & dev dependencies
64
+ if: ${{ inputs.sync-mode == 'project' }}
65
+ shell: bash
66
+ run: uv sync --locked --group dev
@@ -19,3 +19,13 @@ updates:
19
19
  - "pyo3"
20
20
  - "flume"
21
21
  - "parking_lot"
22
+
23
+ # GitHub Actions workflows & composite actions
24
+ - package-ecosystem: "github-actions"
25
+ directory: "/"
26
+ schedule:
27
+ interval: "weekly"
28
+ groups:
29
+ actions:
30
+ patterns:
31
+ - "*"
@@ -18,17 +18,14 @@
18
18
  ## Checklist
19
19
 
20
20
  <!--
21
- Before submitting, make sure the pre-submission checklist passes.
21
+ Before submitting, make sure `make all` (or the relevant docs check) passes.
22
22
  See CONTRIBUTING.md -> "Pre-submission checklist" for details.
23
23
  -->
24
24
 
25
- - [ ] Tests pass (`uv run pytest -x -m "not slow"`)
26
- - [ ] Lint passes (`uv run ruff check .`)
27
- - [ ] Type check passes (`uv run mypy --strict src/multiloop`)
28
- - [ ] Rust clippy passes (`cargo clippy -- -D warnings`)
29
- - [ ] Rust fmt (`cargo fmt --check`)
30
- - [ ] CHANGELOG updated (if applicable)
31
- - [ ] EN/ZH docs synced (`README.md` ↔ `README_ZH.md`, `docs/*.md` ↔ `docs/*_ZH.md` — mirrors must stay identical in structure)
25
+ - [ ] Tests pass (`make test` on free-threaded Python `>= 3.14t`)
26
+ - [ ] Lint & static checks pass (`make lint`: ruff check/format, mypy, pyright, clippy, rustfmt, rustdoc, version parity)
27
+ - [ ] CHANGELOG / CITATION updated (if cutting a release)
28
+ - [ ] EN/ZH docs synced (`README.md` ↔ `README_ZH.md`, `docs/*.md` ↔ `docs/*_ZH.md`, `examples/README.md` ↔ `examples/README_ZH.md`)
32
29
 
33
30
  ## Related issue
34
31
 
@@ -0,0 +1,120 @@
1
+ """Shared helpers for cross-platform CI and distribution Python scripts."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import contextlib
6
+ import os
7
+ import pathlib
8
+ import subprocess
9
+ import sys
10
+ from typing import TYPE_CHECKING
11
+
12
+ if TYPE_CHECKING:
13
+ from collections.abc import Iterator
14
+
15
+ ROOT = pathlib.Path(__file__).resolve().parents[2]
16
+ DEFAULT_VERSIONS = ("3.14t", "3.15t")
17
+
18
+
19
+ def parse_versions(cli_versions: list[str]) -> list[str]:
20
+ """Resolve target Python versions from CLI args, PYTHON_VERSIONS env var, or defaults."""
21
+ if cli_versions:
22
+ return cli_versions
23
+ env_val = os.environ.get("PYTHON_VERSIONS", "").strip()
24
+ if env_val:
25
+ return env_val.split()
26
+ return list(DEFAULT_VERSIONS)
27
+
28
+
29
+ def parse_major_minor(version_tag: str) -> tuple[int, int]:
30
+ """Parse ``'3.14t'`` or ``'3.15'`` into ``(major, minor)``."""
31
+ cleaned = version_tag.removesuffix("t")
32
+ parts = cleaned.split(".")
33
+ if len(parts) != 2 or not all(part.isdigit() for part in parts):
34
+ raise ValueError(f"Expected '<major>.<minor>[t]' version spec, got {version_tag!r}")
35
+ return int(parts[0]), int(parts[1])
36
+
37
+
38
+ def venv_python_path(venv_dir: pathlib.Path) -> pathlib.Path:
39
+ """Return the Python executable inside ``venv_dir``."""
40
+ if sys.platform == "win32":
41
+ return venv_dir / "Scripts" / "python.exe"
42
+ return venv_dir / "bin" / "python"
43
+
44
+
45
+ def base_uv_env(venv_dir: pathlib.Path | None = None) -> dict[str, str]:
46
+ """Build a clean environment for child ``uv`` invocations."""
47
+ env = os.environ.copy()
48
+ env.pop("UV_PYTHON", None)
49
+ env.pop("PYO3_PYTHON", None)
50
+ if venv_dir is None:
51
+ env.pop("VIRTUAL_ENV", None)
52
+ env.pop("UV_PROJECT_ENVIRONMENT", None)
53
+ else:
54
+ env["UV_PROJECT_ENVIRONMENT"] = str(venv_dir)
55
+ env["VIRTUAL_ENV"] = str(venv_dir)
56
+ bin_dir = str(venv_python_path(venv_dir).parent)
57
+ existing_path = env.get("PATH", "")
58
+ env["PATH"] = f"{bin_dir}{os.pathsep}{existing_path}" if existing_path else bin_dir
59
+ return env
60
+
61
+
62
+ def run_cmd(cmd: list[str], env: dict[str, str] | None = None) -> None:
63
+ """Print and execute ``cmd`` in the repository root, failing loudly on non-zero exit."""
64
+ print(f"+ {' '.join(cmd)}", flush=True)
65
+ subprocess.run(cmd, cwd=ROOT, env=env, check=True)
66
+
67
+
68
+ def find_managed_python(version: str) -> str:
69
+ """Locate (and install if missing) a ``uv``-managed interpreter for ``version``."""
70
+ env = base_uv_env()
71
+ find_cmd = ["uv", "python", "find", "--system", "--managed-python", version]
72
+ probe = subprocess.run(find_cmd, cwd=ROOT, env=env, text=True, capture_output=True, check=False)
73
+ if probe.returncode != 0:
74
+ run_cmd(["uv", "python", "install", version], env=env)
75
+ probe = subprocess.run(
76
+ find_cmd, cwd=ROOT, env=env, text=True, capture_output=True, check=True
77
+ )
78
+ resolved = probe.stdout.strip().splitlines()[-1].strip()
79
+ if not resolved:
80
+ raise RuntimeError(f"uv python find returned empty path for {version}")
81
+ return resolved
82
+
83
+
84
+ def ensure_venv(version: str, venv_dir: pathlib.Path) -> tuple[pathlib.Path, dict[str, str]]:
85
+ """Provision/sync ``venv_dir`` for ``version`` and return ``(venv_python, child_env)``."""
86
+ managed_python = find_managed_python(version)
87
+ env = base_uv_env(venv_dir)
88
+ run_cmd(
89
+ [
90
+ "uv",
91
+ "sync",
92
+ "--locked",
93
+ "--no-install-project",
94
+ "--group",
95
+ "dev",
96
+ "--python",
97
+ managed_python,
98
+ ],
99
+ env=env,
100
+ )
101
+ venv_py = venv_python_path(venv_dir)
102
+ if not venv_py.exists():
103
+ raise RuntimeError(f"Expected venv Python executable missing: {venv_py}")
104
+ env["PYO3_PYTHON"] = str(venv_py)
105
+ return venv_py, env
106
+
107
+
108
+ @contextlib.contextmanager
109
+ def ci_group(title: str) -> Iterator[None]:
110
+ """Emit collapsible GitHub Actions log groups or clear local section headers."""
111
+ in_gha = os.environ.get("GITHUB_ACTIONS") == "true"
112
+ if in_gha:
113
+ print(f"::group::{title}", flush=True)
114
+ else:
115
+ print(f"\n=== {title} ===", flush=True)
116
+ try:
117
+ yield
118
+ finally:
119
+ if in_gha:
120
+ print("::endgroup::", flush=True)
@@ -0,0 +1,48 @@
1
+ """Build distribution wheels for all target free-threaded Python versions on one OS."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import sys
7
+
8
+ from _common import ROOT, ci_group, ensure_venv, find_managed_python, parse_versions, run_cmd
9
+
10
+
11
+ def main(argv: list[str]) -> int:
12
+ parser = argparse.ArgumentParser(description="Build wheels for target Python versions.")
13
+ parser.add_argument("--target", default="", help="Optional Rust/maturin target triple or arch.")
14
+ parser.add_argument("--out", default="dist", help="Output directory for built wheels.")
15
+ parser.add_argument("versions", nargs="*", help="Target Python versions (e.g. 3.14t 3.15t).")
16
+ args = parser.parse_args(argv)
17
+
18
+ versions = parse_versions(args.versions)
19
+ with ci_group(f"Build wheels ({', '.join(versions)})"):
20
+ interpreters = [find_managed_python(ver) for ver in versions]
21
+ venv_py, env = ensure_venv(versions[0], ROOT / ".venv-build")
22
+ # Let maturin configure PYO3_PYTHON independently per --interpreter.
23
+ env.pop("PYO3_PYTHON", None)
24
+ cmd = [
25
+ "uv",
26
+ "run",
27
+ "--no-sync",
28
+ "--python",
29
+ str(venv_py),
30
+ "maturin",
31
+ "build",
32
+ "--release",
33
+ "--locked",
34
+ "--out",
35
+ args.out,
36
+ "--compatibility",
37
+ "pypi",
38
+ ]
39
+ if args.target:
40
+ cmd.extend(["--target", args.target])
41
+ cmd.append("--interpreter")
42
+ cmd.extend(interpreters)
43
+ run_cmd(cmd, env=env)
44
+ return 0
45
+
46
+
47
+ if __name__ == "__main__":
48
+ raise SystemExit(main(sys.argv[1:]))
@@ -0,0 +1,105 @@
1
+ """Verify package version and release metadata consistency across repository files."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import pathlib
7
+ import re
8
+ import sys
9
+ import tomllib
10
+
11
+ ROOT = pathlib.Path(__file__).resolve().parents[2]
12
+
13
+
14
+ def _read_pyproject_version() -> str:
15
+ data = tomllib.loads((ROOT / "pyproject.toml").read_text(encoding="utf-8"))
16
+ project = data.get("project")
17
+ if not isinstance(project, dict) or not isinstance(project.get("version"), str):
18
+ raise RuntimeError("Missing [project].version in pyproject.toml")
19
+ return project["version"]
20
+
21
+
22
+ def _read_cargo_version() -> str:
23
+ data = tomllib.loads((ROOT / "Cargo.toml").read_text(encoding="utf-8"))
24
+ package = data.get("package")
25
+ if not isinstance(package, dict) or not isinstance(package.get("version"), str):
26
+ raise RuntimeError("Missing [package].version in Cargo.toml")
27
+ return package["version"]
28
+
29
+
30
+ def _read_citation_version() -> str:
31
+ text = (ROOT / "CITATION.cff").read_text(encoding="utf-8")
32
+ match = re.search(r'^version:\s*["\']?([^\s"\'#]+)["\']?', text, re.MULTILINE)
33
+ if match is None:
34
+ raise RuntimeError("Missing version field in CITATION.cff")
35
+ return match.group(1)
36
+
37
+
38
+ def _read_python_dunder_version() -> str:
39
+ text = (ROOT / "src" / "multiloop" / "__init__.py").read_text(encoding="utf-8")
40
+ match = re.search(r'^__version__\s*=\s*["\']([^"\']+)["\']', text, re.MULTILINE)
41
+ if match is None:
42
+ raise RuntimeError("Missing __version__ in src/multiloop/__init__.py")
43
+ return match.group(1)
44
+
45
+
46
+ def _check_changelog(version: str) -> None:
47
+ text = (ROOT / "CHANGELOG.md").read_text(encoding="utf-8")
48
+ pattern = rf"^##\s+\[{re.escape(version)}\](?:\s|$)"
49
+ if re.search(pattern, text, re.MULTILINE) is None:
50
+ raise RuntimeError(f"CHANGELOG.md does not contain a '## [{version}]' section")
51
+
52
+
53
+ def main(argv: list[str]) -> int:
54
+ parser = argparse.ArgumentParser(description="Verify release version parity across manifests.")
55
+ parser.add_argument(
56
+ "--tag",
57
+ default="",
58
+ help="Optional git tag/ref name (e.g. v0.1.3) to compare against manifest version.",
59
+ )
60
+ parser.add_argument(
61
+ "--require-changelog",
62
+ action="store_true",
63
+ help="Require a matching '## [<version>]' entry in CHANGELOG.md.",
64
+ )
65
+ args = parser.parse_args(argv)
66
+
67
+ py_version = _read_pyproject_version()
68
+ cargo_version = _read_cargo_version()
69
+ citation_version = _read_citation_version()
70
+ dunder_version = _read_python_dunder_version()
71
+
72
+ errors: list[str] = []
73
+ if cargo_version != py_version:
74
+ errors.append(
75
+ f"Version mismatch: pyproject.toml={py_version} != Cargo.toml={cargo_version}"
76
+ )
77
+ if citation_version != py_version:
78
+ errors.append(
79
+ f"Version mismatch: pyproject.toml={py_version} != CITATION.cff={citation_version}"
80
+ )
81
+ if dunder_version != py_version:
82
+ errors.append(
83
+ f"Version mismatch: pyproject.toml={py_version} != __init__.py={dunder_version}"
84
+ )
85
+ if args.tag:
86
+ tag_version = args.tag.removeprefix("v")
87
+ if tag_version != py_version:
88
+ errors.append(f"Version mismatch: tag={args.tag} != pyproject.toml={py_version}")
89
+ if args.require_changelog:
90
+ try:
91
+ _check_changelog(py_version)
92
+ except RuntimeError as exc:
93
+ errors.append(str(exc))
94
+
95
+ if errors:
96
+ for err in errors:
97
+ print(f"ERROR: {err}", file=sys.stderr)
98
+ return 1
99
+
100
+ print(f"OK: release metadata consistent at version {py_version}")
101
+ return 0
102
+
103
+
104
+ if __name__ == "__main__":
105
+ raise SystemExit(main(sys.argv[1:]))
@@ -0,0 +1,66 @@
1
+ """Build and run Rust + Python test suites sequentially across Python versions on one OS."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import sys
7
+
8
+ from _common import ROOT, ci_group, ensure_venv, parse_major_minor, parse_versions, run_cmd
9
+
10
+
11
+ def _verify_runtime(venv_py: str, version_tag: str, env: dict[str, str]) -> None:
12
+ major, minor = parse_major_minor(version_tag)
13
+ expect_nogil = version_tag.endswith("t")
14
+ snippet = (
15
+ "import sys; "
16
+ f"assert sys.version_info[:2] == ({major}, {minor}), sys.version; "
17
+ f"assert (hasattr(sys, '_is_gil_enabled') and not sys._is_gil_enabled()) == {expect_nogil!r}, "
18
+ "'unexpected GIL mode'"
19
+ )
20
+ run_cmd(["uv", "run", "--no-sync", "--python", venv_py, "python", "-c", snippet], env=env)
21
+
22
+
23
+ def main(argv: list[str]) -> int:
24
+ parser = argparse.ArgumentParser(description="Run CI builds and tests across Python versions.")
25
+ parser.add_argument("versions", nargs="*", help="Target Python versions (e.g. 3.14t 3.15t).")
26
+ args = parser.parse_args(argv)
27
+
28
+ versions = parse_versions(args.versions)
29
+ for ver in versions:
30
+ with ci_group(f"Python {ver}: build & test"):
31
+ venv_dir = ROOT / f".venv-ci-{ver}"
32
+ venv_py, env = ensure_venv(ver, venv_dir)
33
+ py_str = str(venv_py)
34
+ _verify_runtime(py_str, ver, env)
35
+ run_cmd(
36
+ [
37
+ "uv",
38
+ "run",
39
+ "--no-sync",
40
+ "--python",
41
+ py_str,
42
+ "maturin",
43
+ "develop",
44
+ "--release",
45
+ "--locked",
46
+ ],
47
+ env=env,
48
+ )
49
+ run_cmd(
50
+ [
51
+ "uv",
52
+ "run",
53
+ "--no-sync",
54
+ "--python",
55
+ py_str,
56
+ "python",
57
+ ".github/scripts/run_rust_tests.py",
58
+ ],
59
+ env=env,
60
+ )
61
+ run_cmd(["uv", "run", "--no-sync", "--python", py_str, "pytest"], env=env)
62
+ return 0
63
+
64
+
65
+ if __name__ == "__main__":
66
+ raise SystemExit(main(sys.argv[1:]))
@@ -0,0 +1,54 @@
1
+ """Run Rust unit tests with the active Python interpreter's shared library path.
2
+
3
+ Standalone ``cargo test`` binaries link against ``libpython`` rather than loading
4
+ symbols from a host process. Managed interpreters (such as ``uv`` Python installs)
5
+ place ``libpython`` outside the default system loader search path, so this helper
6
+ prepends the base interpreter library directory before invoking ``cargo test``.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import os
12
+ import subprocess
13
+ import sys
14
+ import sysconfig
15
+
16
+
17
+ def _python_lib_dir() -> tuple[str, str]:
18
+ """Return ``(env_var_name, directory_path)`` for locating ``libpython``."""
19
+ if sys.platform == "win32":
20
+ # On Windows, python3xx.dll resides in the base interpreter root rather
21
+ # than the venv copy or LIBDIR (which holds import .lib files).
22
+ return "PATH", sys.base_prefix
23
+
24
+ lib_dir = sysconfig.get_config_var("LIBDIR")
25
+ if not isinstance(lib_dir, str) or not lib_dir:
26
+ lib_dir = os.path.join(sys.base_prefix, "lib")
27
+
28
+ env_var = "DYLD_FALLBACK_LIBRARY_PATH" if sys.platform == "darwin" else "LD_LIBRARY_PATH"
29
+ return env_var, lib_dir
30
+
31
+
32
+ def main(argv: list[str]) -> int:
33
+ env_var, lib_dir = _python_lib_dir()
34
+ env = os.environ.copy()
35
+ existing = env.get(env_var, "")
36
+ env[env_var] = f"{lib_dir}{os.pathsep}{existing}" if existing else lib_dir
37
+ env.setdefault("PYO3_PYTHON", sys.executable)
38
+
39
+ cmd = [
40
+ "cargo",
41
+ "test",
42
+ "--lib",
43
+ "--no-default-features",
44
+ "--features",
45
+ "test-init",
46
+ "--locked",
47
+ *argv,
48
+ ]
49
+ result = subprocess.run(cmd, env=env, check=False)
50
+ return result.returncode
51
+
52
+
53
+ if __name__ == "__main__":
54
+ raise SystemExit(main(sys.argv[1:]))