multiloop 0.1.0__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.
- multiloop-0.1.0/.editorconfig +21 -0
- multiloop-0.1.0/.github/FUNDING.yml +1 -0
- multiloop-0.1.0/.github/ISSUE_TEMPLATE/bug_report.yml +57 -0
- multiloop-0.1.0/.github/ISSUE_TEMPLATE/feature_request.yml +36 -0
- multiloop-0.1.0/.github/dependabot.yml +21 -0
- multiloop-0.1.0/.github/pull_request_template.md +35 -0
- multiloop-0.1.0/.github/release-drafter.yml +36 -0
- multiloop-0.1.0/.github/workflows/ci.yml +218 -0
- multiloop-0.1.0/.github/workflows/publish.yml +264 -0
- multiloop-0.1.0/.github/workflows/release-drafter.yml +24 -0
- multiloop-0.1.0/.gitignore +42 -0
- multiloop-0.1.0/.pre-commit-config.yaml +32 -0
- multiloop-0.1.0/.python-version +1 -0
- multiloop-0.1.0/AGENTS.md +394 -0
- multiloop-0.1.0/CHANGELOG.md +39 -0
- multiloop-0.1.0/CITATION.cff +11 -0
- multiloop-0.1.0/CODEOWNERS +1 -0
- multiloop-0.1.0/CODE_OF_CONDUCT.md +77 -0
- multiloop-0.1.0/CONTRIBUTING.md +213 -0
- multiloop-0.1.0/Cargo.lock +551 -0
- multiloop-0.1.0/Cargo.toml +34 -0
- multiloop-0.1.0/LICENSE +21 -0
- multiloop-0.1.0/Makefile +42 -0
- multiloop-0.1.0/PKG-INFO +356 -0
- multiloop-0.1.0/README.md +328 -0
- multiloop-0.1.0/README_ZH.md +327 -0
- multiloop-0.1.0/SECURITY.md +58 -0
- multiloop-0.1.0/benchmarks/bench_asgi_throughput.py +209 -0
- multiloop-0.1.0/benchmarks/bench_multithread_loops.py +106 -0
- multiloop-0.1.0/benchmarks/benchmark_pull_model.py +79 -0
- multiloop-0.1.0/build.rs +30 -0
- multiloop-0.1.0/deny.toml +14 -0
- multiloop-0.1.0/docs/API.md +937 -0
- multiloop-0.1.0/docs/API_ZH.md +993 -0
- multiloop-0.1.0/docs/CHOOSING.md +116 -0
- multiloop-0.1.0/docs/CHOOSING_ZH.md +103 -0
- multiloop-0.1.0/docs/CONCURRENCY.md +418 -0
- multiloop-0.1.0/docs/CONCURRENCY_ZH.md +365 -0
- multiloop-0.1.0/examples/00_pool_basics.py +35 -0
- multiloop-0.1.0/examples/01_channels_select.py +52 -0
- multiloop-0.1.0/examples/02_waitgroup_once.py +57 -0
- multiloop-0.1.0/examples/03_taskgroup_timeout.py +58 -0
- multiloop-0.1.0/examples/04_sync_primitives.py +85 -0
- multiloop-0.1.0/examples/05_asgi_websocket.py +71 -0
- multiloop-0.1.0/examples/06_wsgi_flask.py +37 -0
- multiloop-0.1.0/examples/README.md +24 -0
- multiloop-0.1.0/examples/README_ZH.md +21 -0
- multiloop-0.1.0/pyproject.toml +107 -0
- multiloop-0.1.0/rust-toolchain.toml +3 -0
- multiloop-0.1.0/src/channel.rs +458 -0
- multiloop-0.1.0/src/h2.rs +359 -0
- multiloop-0.1.0/src/http.rs +61 -0
- multiloop-0.1.0/src/lib.rs +664 -0
- multiloop-0.1.0/src/metrics.rs +137 -0
- multiloop-0.1.0/src/multiloop/__init__.py +121 -0
- multiloop-0.1.0/src/multiloop/__init__.pyi +451 -0
- multiloop-0.1.0/src/multiloop/_cancel.py +466 -0
- multiloop-0.1.0/src/multiloop/_channel_base.py +338 -0
- multiloop-0.1.0/src/multiloop/_logging.py +54 -0
- multiloop-0.1.0/src/multiloop/_metrics.py +103 -0
- multiloop-0.1.0/src/multiloop/_multiloop_core.pyi +70 -0
- multiloop-0.1.0/src/multiloop/_options.py +43 -0
- multiloop-0.1.0/src/multiloop/_rust.py +23 -0
- multiloop-0.1.0/src/multiloop/_sync.py +772 -0
- multiloop-0.1.0/src/multiloop/_taskgroup.py +388 -0
- multiloop-0.1.0/src/multiloop/asgi.py +784 -0
- multiloop-0.1.0/src/multiloop/cli.py +275 -0
- multiloop-0.1.0/src/multiloop/context.py +168 -0
- multiloop-0.1.0/src/multiloop/exceptions.py +37 -0
- multiloop-0.1.0/src/multiloop/pool.py +614 -0
- multiloop-0.1.0/src/multiloop/primitives.py +729 -0
- multiloop-0.1.0/src/multiloop/py.typed +1 -0
- multiloop-0.1.0/src/multiloop/rwlock.py +142 -0
- multiloop-0.1.0/src/multiloop/server.py +314 -0
- multiloop-0.1.0/src/multiloop/testing/__init__.py +30 -0
- multiloop-0.1.0/src/multiloop/wsgi.py +311 -0
- multiloop-0.1.0/src/pool.rs +256 -0
- multiloop-0.1.0/src/waitgroup.rs +115 -0
- multiloop-0.1.0/tests/conftest.py +15 -0
- multiloop-0.1.0/tests/test_asgi_lifespan_ws.py +551 -0
- multiloop-0.1.0/tests/test_cancel_scope.py +987 -0
- multiloop-0.1.0/tests/test_channel.py +1054 -0
- multiloop-0.1.0/tests/test_cli.py +46 -0
- multiloop-0.1.0/tests/test_docs.py +123 -0
- multiloop-0.1.0/tests/test_free_threading.py +222 -0
- multiloop-0.1.0/tests/test_go_parity.py +274 -0
- multiloop-0.1.0/tests/test_logging.py +36 -0
- multiloop-0.1.0/tests/test_loop_factory.py +25 -0
- multiloop-0.1.0/tests/test_perf_regression.py +86 -0
- multiloop-0.1.0/tests/test_pool.py +915 -0
- multiloop-0.1.0/tests/test_regression_bugs.py +386 -0
- multiloop-0.1.0/tests/test_server.py +444 -0
- multiloop-0.1.0/tests/test_sync_condition_barrier.py +668 -0
- multiloop-0.1.0/tests/test_sync_lock_event.py +631 -0
- multiloop-0.1.0/tests/test_sync_primitives.py +801 -0
- multiloop-0.1.0/tests/test_taskgroup.py +712 -0
- multiloop-0.1.0/tests/test_wsgi.py +127 -0
- multiloop-0.1.0/uv.lock +545 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
root = true
|
|
2
|
+
|
|
3
|
+
[*]
|
|
4
|
+
charset = utf-8
|
|
5
|
+
end_of_line = lf
|
|
6
|
+
insert_final_newline = true
|
|
7
|
+
indent_style = space
|
|
8
|
+
indent_size = 4
|
|
9
|
+
trim_trailing_whitespace = true
|
|
10
|
+
|
|
11
|
+
[*.{yml,yaml}]
|
|
12
|
+
indent_size = 2
|
|
13
|
+
|
|
14
|
+
[Makefile]
|
|
15
|
+
indent_style = tab
|
|
16
|
+
|
|
17
|
+
[*.rs]
|
|
18
|
+
indent_size = 4
|
|
19
|
+
|
|
20
|
+
[*.{md,rst}]
|
|
21
|
+
trim_trailing_whitespace = false
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
github: [hankaihong1]
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
name: Bug Report
|
|
2
|
+
description: Report a bug in multiloop
|
|
3
|
+
labels: ["bug"]
|
|
4
|
+
body:
|
|
5
|
+
- type: textarea
|
|
6
|
+
id: description
|
|
7
|
+
attributes:
|
|
8
|
+
label: Describe the bug
|
|
9
|
+
description: A clear and concise description of what the bug is.
|
|
10
|
+
placeholder: What went wrong?
|
|
11
|
+
validations:
|
|
12
|
+
required: true
|
|
13
|
+
|
|
14
|
+
- type: textarea
|
|
15
|
+
id: repro
|
|
16
|
+
attributes:
|
|
17
|
+
label: To Reproduce
|
|
18
|
+
description: Steps to reproduce the behavior. Include a minimal code example if possible.
|
|
19
|
+
placeholder: |
|
|
20
|
+
```python
|
|
21
|
+
import multiloop
|
|
22
|
+
|
|
23
|
+
# minimal reproduction snippet
|
|
24
|
+
```
|
|
25
|
+
render: python
|
|
26
|
+
validations:
|
|
27
|
+
required: true
|
|
28
|
+
|
|
29
|
+
- type: textarea
|
|
30
|
+
id: expected
|
|
31
|
+
attributes:
|
|
32
|
+
label: Expected behavior
|
|
33
|
+
description: What did you expect to happen instead?
|
|
34
|
+
placeholder: I expected ...
|
|
35
|
+
validations:
|
|
36
|
+
required: true
|
|
37
|
+
|
|
38
|
+
- type: textarea
|
|
39
|
+
id: environment
|
|
40
|
+
attributes:
|
|
41
|
+
label: Environment
|
|
42
|
+
description: Your runtime environment. This project requires Python 3.14t (free-threaded build).
|
|
43
|
+
value: |
|
|
44
|
+
- OS: [e.g. macOS 15, Ubuntu 24.04]
|
|
45
|
+
- Python version: [e.g. 3.14.0t]
|
|
46
|
+
- multiloop version: [e.g. 0.1.0]
|
|
47
|
+
- Rust toolchain: [e.g. stable]
|
|
48
|
+
render: markdown
|
|
49
|
+
validations:
|
|
50
|
+
required: true
|
|
51
|
+
|
|
52
|
+
- type: textarea
|
|
53
|
+
id: context
|
|
54
|
+
attributes:
|
|
55
|
+
label: Additional context
|
|
56
|
+
description: Any other information, logs, or screenshots that might help.
|
|
57
|
+
placeholder: Add anything else here.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
name: Feature Request
|
|
2
|
+
description: Suggest an idea or enhancement for this project
|
|
3
|
+
labels: ["enhancement"]
|
|
4
|
+
body:
|
|
5
|
+
- type: textarea
|
|
6
|
+
id: problem
|
|
7
|
+
attributes:
|
|
8
|
+
label: Problem statement
|
|
9
|
+
description: What problem are you trying to solve? Why is this feature needed?
|
|
10
|
+
placeholder: Describe the problem you are facing...
|
|
11
|
+
validations:
|
|
12
|
+
required: true
|
|
13
|
+
- type: textarea
|
|
14
|
+
id: solution
|
|
15
|
+
attributes:
|
|
16
|
+
label: Proposed solution
|
|
17
|
+
description: What should the feature do? How should it behave?
|
|
18
|
+
placeholder: Describe your proposed solution...
|
|
19
|
+
validations:
|
|
20
|
+
required: true
|
|
21
|
+
- type: textarea
|
|
22
|
+
id: alternatives
|
|
23
|
+
attributes:
|
|
24
|
+
label: Alternatives considered
|
|
25
|
+
description: What alternatives have you considered or tried?
|
|
26
|
+
placeholder: Describe any alternative approaches...
|
|
27
|
+
validations:
|
|
28
|
+
required: false
|
|
29
|
+
- type: textarea
|
|
30
|
+
id: context
|
|
31
|
+
attributes:
|
|
32
|
+
label: Additional context
|
|
33
|
+
description: Any other information, screenshots, or links that help explain the request.
|
|
34
|
+
placeholder: Add any additional context here...
|
|
35
|
+
validations:
|
|
36
|
+
required: false
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Dependabot configuration for multiloop
|
|
2
|
+
#
|
|
3
|
+
# Note: The pip ecosystem is intentionally NOT configured here.
|
|
4
|
+
# All Python dependencies live in PEP 735 [dependency-groups] (see
|
|
5
|
+
# pyproject.toml), which Dependabot's pip ecosystem does not support.
|
|
6
|
+
# Adding a pip entry would silently do nothing, so it is deferred until
|
|
7
|
+
# Dependabot gains PEP 735 support.
|
|
8
|
+
|
|
9
|
+
version: 2
|
|
10
|
+
updates:
|
|
11
|
+
# Rust workspace (multiloop-core engine): pyo3, flume, parking_lot
|
|
12
|
+
- package-ecosystem: "cargo"
|
|
13
|
+
directory: "/"
|
|
14
|
+
schedule:
|
|
15
|
+
interval: "weekly"
|
|
16
|
+
groups:
|
|
17
|
+
rust-deps:
|
|
18
|
+
patterns:
|
|
19
|
+
- "pyo3"
|
|
20
|
+
- "flume"
|
|
21
|
+
- "parking_lot"
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Pull Request
|
|
2
|
+
|
|
3
|
+
## Description of changes
|
|
4
|
+
|
|
5
|
+
<!-- Describe what you changed and why. Include *what* and *why*, not just *how*. -->
|
|
6
|
+
|
|
7
|
+
## Type
|
|
8
|
+
|
|
9
|
+
- [ ] bugfix
|
|
10
|
+
- [ ] feature
|
|
11
|
+
- [ ] docs
|
|
12
|
+
- [ ] chore
|
|
13
|
+
|
|
14
|
+
> **Labels**: after opening the PR, add the matching label
|
|
15
|
+
> (`feature` / `fix` / `docs` / `chore` / `breaking`) — Release Drafter
|
|
16
|
+
> groups PRs by label and derives the next version number from them.
|
|
17
|
+
|
|
18
|
+
## Checklist
|
|
19
|
+
|
|
20
|
+
<!--
|
|
21
|
+
Before submitting, make sure the pre-submission checklist passes.
|
|
22
|
+
See CONTRIBUTING.md -> "Pre-submission checklist" for details.
|
|
23
|
+
-->
|
|
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)
|
|
32
|
+
|
|
33
|
+
## Related issue
|
|
34
|
+
|
|
35
|
+
Closes #<issue>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
name-template: 'v$RESOLVED_VERSION'
|
|
2
|
+
tag-template: 'v$RESOLVED_VERSION'
|
|
3
|
+
|
|
4
|
+
categories:
|
|
5
|
+
- title: '🚀 Features'
|
|
6
|
+
label: 'feature'
|
|
7
|
+
- title: '🐛 Bug Fixes'
|
|
8
|
+
label: 'fix'
|
|
9
|
+
- title: '🧹 Chores'
|
|
10
|
+
label: 'chore'
|
|
11
|
+
- title: '📚 Documentation'
|
|
12
|
+
label: 'docs'
|
|
13
|
+
- title: '💥 Breaking Changes'
|
|
14
|
+
label: 'breaking'
|
|
15
|
+
|
|
16
|
+
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
|
|
17
|
+
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
|
|
18
|
+
|
|
19
|
+
version-resolver:
|
|
20
|
+
major:
|
|
21
|
+
labels:
|
|
22
|
+
- 'breaking'
|
|
23
|
+
minor:
|
|
24
|
+
labels:
|
|
25
|
+
- 'feature'
|
|
26
|
+
patch:
|
|
27
|
+
labels:
|
|
28
|
+
- 'fix'
|
|
29
|
+
- 'chore'
|
|
30
|
+
- 'docs'
|
|
31
|
+
default: patch
|
|
32
|
+
|
|
33
|
+
template: |
|
|
34
|
+
## Changes
|
|
35
|
+
|
|
36
|
+
$CHANGES
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ main ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ main ]
|
|
8
|
+
|
|
9
|
+
concurrency:
|
|
10
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
11
|
+
cancel-in-progress: true
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
# Classify every push/PR before anything heavy runs. Docs-only changes
|
|
15
|
+
# skip the lint + build/test matrix (their jobs report "skipped", which
|
|
16
|
+
# GitHub counts as success for required checks) and run only the Docs
|
|
17
|
+
# Drift Check; anything touching code runs the full suite. The two
|
|
18
|
+
# filters are exact complements, so a mixed change sets both to true
|
|
19
|
+
# and gets both gates.
|
|
20
|
+
changes:
|
|
21
|
+
name: Detect Changed Files
|
|
22
|
+
runs-on: ubuntu-latest
|
|
23
|
+
permissions:
|
|
24
|
+
contents: read
|
|
25
|
+
pull-requests: read
|
|
26
|
+
outputs:
|
|
27
|
+
code: ${{ steps.filter.outputs.code }}
|
|
28
|
+
docs: ${{ steps.filter.outputs.docs }}
|
|
29
|
+
steps:
|
|
30
|
+
- uses: actions/checkout@v4
|
|
31
|
+
|
|
32
|
+
- uses: dorny/paths-filter@v4
|
|
33
|
+
id: filter
|
|
34
|
+
with:
|
|
35
|
+
base: main
|
|
36
|
+
# '!' exclusions only take effect with 'some-with-excludes';
|
|
37
|
+
# under the default 'some' they are ignored, and a filter made
|
|
38
|
+
# of negations only never matches anything.
|
|
39
|
+
predicate-quantifier: 'some-with-excludes'
|
|
40
|
+
filters: |
|
|
41
|
+
docs:
|
|
42
|
+
- '**/*.md'
|
|
43
|
+
- 'docs/**'
|
|
44
|
+
code:
|
|
45
|
+
- '**'
|
|
46
|
+
- '!**/*.md'
|
|
47
|
+
- '!docs/**'
|
|
48
|
+
|
|
49
|
+
lint:
|
|
50
|
+
name: Lint & Static Analysis
|
|
51
|
+
needs: changes
|
|
52
|
+
# Skipped on docs-only changes; runs when the classifier itself failed
|
|
53
|
+
# (fail-closed: an unknown change set must not sail through unverified).
|
|
54
|
+
if: needs.changes.outputs.code == 'true' || needs.changes.result != 'success'
|
|
55
|
+
runs-on: ubuntu-latest
|
|
56
|
+
steps:
|
|
57
|
+
- uses: actions/checkout@v4
|
|
58
|
+
|
|
59
|
+
- name: Install Rust toolchain
|
|
60
|
+
uses: dtolnay/rust-toolchain@stable
|
|
61
|
+
with:
|
|
62
|
+
components: clippy, rustfmt
|
|
63
|
+
|
|
64
|
+
- name: Set up uv & Python 3.14t
|
|
65
|
+
uses: astral-sh/setup-uv@v5
|
|
66
|
+
with:
|
|
67
|
+
enable-cache: true
|
|
68
|
+
python-version: "3.14t"
|
|
69
|
+
|
|
70
|
+
- name: Install dependencies
|
|
71
|
+
run: uv sync --group dev
|
|
72
|
+
|
|
73
|
+
- name: Cargo Clippy & Format Check
|
|
74
|
+
run: |
|
|
75
|
+
cargo clippy -- -D warnings
|
|
76
|
+
cargo fmt --check
|
|
77
|
+
|
|
78
|
+
- name: Python Strict Static Analysis (Mypy, Pyright & Ruff)
|
|
79
|
+
run: |
|
|
80
|
+
uv run mypy --strict src/multiloop
|
|
81
|
+
uv run pyright src/multiloop
|
|
82
|
+
uv run ruff check .
|
|
83
|
+
|
|
84
|
+
- name: Cargo Deny Check
|
|
85
|
+
uses: EmbarkStudios/cargo-deny-action@v2
|
|
86
|
+
with:
|
|
87
|
+
command: check advisories
|
|
88
|
+
|
|
89
|
+
- name: Rustdoc Check
|
|
90
|
+
env:
|
|
91
|
+
RUSTDOCFLAGS: "-D warnings"
|
|
92
|
+
run: |
|
|
93
|
+
cargo doc --no-deps --document-private-items
|
|
94
|
+
|
|
95
|
+
test:
|
|
96
|
+
name: Build & Test (Python ${{ matrix.python-version }}, ${{ matrix.os }})
|
|
97
|
+
needs: [changes, lint]
|
|
98
|
+
# The explicit if replaces the implicit success(): (code == 'true' &&
|
|
99
|
+
# success()) preserves the old "no matrix when lint failed" behavior,
|
|
100
|
+
# while the || result != 'success' branch keeps the run fail-closed
|
|
101
|
+
# when the classifier job itself failed.
|
|
102
|
+
if: (needs.changes.outputs.code == 'true' && success()) || needs.changes.result != 'success'
|
|
103
|
+
strategy:
|
|
104
|
+
fail-fast: false
|
|
105
|
+
matrix:
|
|
106
|
+
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
107
|
+
python-version: ["3.14", "3.14t"]
|
|
108
|
+
runs-on: ${{ matrix.os }}
|
|
109
|
+
|
|
110
|
+
steps:
|
|
111
|
+
- uses: actions/checkout@v4
|
|
112
|
+
|
|
113
|
+
- name: Install Rust toolchain
|
|
114
|
+
uses: dtolnay/rust-toolchain@stable
|
|
115
|
+
|
|
116
|
+
- name: Set up uv & Python ${{ matrix.python-version }}
|
|
117
|
+
uses: astral-sh/setup-uv@v5
|
|
118
|
+
with:
|
|
119
|
+
enable-cache: true
|
|
120
|
+
python-version: ${{ matrix.python-version }}
|
|
121
|
+
|
|
122
|
+
- name: Install dependencies
|
|
123
|
+
run: uv sync --group dev
|
|
124
|
+
|
|
125
|
+
- name: Build Rust Extension
|
|
126
|
+
run: |
|
|
127
|
+
uv run maturin develop --release
|
|
128
|
+
|
|
129
|
+
- name: Run Rust Unit Tests
|
|
130
|
+
shell: bash
|
|
131
|
+
run: |
|
|
132
|
+
# WHY: cargo test 的二进制是 standalone 构建(非 extension-module),
|
|
133
|
+
# 运行时需要加载 libpython。setup-uv 装的解释器不在系统 loader 路径里,
|
|
134
|
+
# 所以要在执行前把解释器目录加进 loader 路径(Linux 用 LD_LIBRARY_PATH,
|
|
135
|
+
# macOS 用 DYLD_FALLBACK_LIBRARY_PATH,Windows 用 PATH 找 python3xx.dll)。
|
|
136
|
+
# 注意 Windows 上 python3xx.dll 在**基础解释器**安装根(venv 的
|
|
137
|
+
# python.exe 是复制出来的,DLL 不复制);sys.base_prefix 在 venv 中
|
|
138
|
+
# 指向基础解释器目录(sys.base_executable 并非跨平台属性,Windows
|
|
139
|
+
# 上不存在);且 bash 的 PATH 用冒号分隔,Windows 路径里的冒号会被
|
|
140
|
+
# 拆断,必须先 cygpath -u 转成 Unix 风格(导出时 Git Bash 会自动
|
|
141
|
+
# 转回 Windows 格式)。
|
|
142
|
+
if [ "$RUNNER_OS" = "Windows" ]; then
|
|
143
|
+
PYDIR="$(uv run python -c 'import sys; print(sys.base_prefix)')"
|
|
144
|
+
export PATH="$(cygpath -u "$PYDIR" 2>/dev/null || echo "$PYDIR"):$PATH"
|
|
145
|
+
elif [ "$RUNNER_OS" = "macOS" ]; then
|
|
146
|
+
export DYLD_FALLBACK_LIBRARY_PATH="$(uv run python -c 'import sysconfig; print(sysconfig.get_config_var("LIBDIR"))'):$DYLD_FALLBACK_LIBRARY_PATH"
|
|
147
|
+
else
|
|
148
|
+
export LD_LIBRARY_PATH="$(uv run python -c 'import sysconfig; print(sysconfig.get_config_var("LIBDIR"))'):$LD_LIBRARY_PATH"
|
|
149
|
+
fi
|
|
150
|
+
cargo test --lib --no-default-features --features test-init --locked
|
|
151
|
+
|
|
152
|
+
- name: Run Test Suite & Race Checks
|
|
153
|
+
run: |
|
|
154
|
+
uv run pytest
|
|
155
|
+
|
|
156
|
+
test_dev:
|
|
157
|
+
name: Build & Test (Python 3.15-dev, ubuntu-latest)
|
|
158
|
+
needs: [changes, lint]
|
|
159
|
+
if: (needs.changes.outputs.code == 'true' && success()) || needs.changes.result != 'success'
|
|
160
|
+
runs-on: ubuntu-latest
|
|
161
|
+
continue-on-error: true
|
|
162
|
+
|
|
163
|
+
steps:
|
|
164
|
+
- uses: actions/checkout@v4
|
|
165
|
+
|
|
166
|
+
- name: Install Rust toolchain
|
|
167
|
+
uses: dtolnay/rust-toolchain@stable
|
|
168
|
+
|
|
169
|
+
# WHY: uv 的 Python 下载请求不认 "3.15-dev" 这种写法(uv 0.12 报 invalid
|
|
170
|
+
# request);写 "3.15" 会自动解析到最新的 3.15 pre-release(当前 3.15.0b4)。
|
|
171
|
+
- name: Set up uv & Python 3.15-dev
|
|
172
|
+
uses: astral-sh/setup-uv@v5
|
|
173
|
+
with:
|
|
174
|
+
enable-cache: true
|
|
175
|
+
python-version: "3.15"
|
|
176
|
+
|
|
177
|
+
- name: Install dependencies
|
|
178
|
+
run: uv sync --group dev
|
|
179
|
+
|
|
180
|
+
- name: Build Rust Extension
|
|
181
|
+
run: |
|
|
182
|
+
uv run maturin develop --release
|
|
183
|
+
|
|
184
|
+
- name: Run Rust Unit Tests
|
|
185
|
+
shell: bash
|
|
186
|
+
run: |
|
|
187
|
+
# WHY: 同 test job——standalone 测试二进制运行时需要 libpython,
|
|
188
|
+
# 解释器 LIBDIR 不在系统 loader 路径里(test_dev 只跑 ubuntu,走 Linux 分支)。
|
|
189
|
+
export LD_LIBRARY_PATH="$(uv run python -c 'import sysconfig; print(sysconfig.get_config_var("LIBDIR"))'):$LD_LIBRARY_PATH"
|
|
190
|
+
cargo test --lib --no-default-features --features test-init --locked
|
|
191
|
+
|
|
192
|
+
- name: Run Test Suite & Race Checks
|
|
193
|
+
run: |
|
|
194
|
+
uv run pytest
|
|
195
|
+
|
|
196
|
+
# Docs-only changes skip the heavy matrix and are gated by this single
|
|
197
|
+
# cheap job (no Rust build: test_docs.py only imports multiloop from src/,
|
|
198
|
+
# which works without the extension via graceful fallback).
|
|
199
|
+
docs:
|
|
200
|
+
name: Docs Drift Check
|
|
201
|
+
needs: changes
|
|
202
|
+
if: needs.changes.outputs.docs == 'true' || needs.changes.result != 'success'
|
|
203
|
+
runs-on: ubuntu-latest
|
|
204
|
+
|
|
205
|
+
steps:
|
|
206
|
+
- uses: actions/checkout@v4
|
|
207
|
+
|
|
208
|
+
- name: Set up uv & Python 3.14t
|
|
209
|
+
uses: astral-sh/setup-uv@v5
|
|
210
|
+
with:
|
|
211
|
+
enable-cache: true
|
|
212
|
+
python-version: "3.14t"
|
|
213
|
+
|
|
214
|
+
- name: Install dev dependencies (skip project build)
|
|
215
|
+
run: uv sync --no-install-project --group dev
|
|
216
|
+
|
|
217
|
+
- name: Run docs drift guard
|
|
218
|
+
run: PYTHONPATH=src uv run --no-sync pytest tests/test_docs.py -q
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
name: Publish
|
|
2
|
+
|
|
3
|
+
# 触发方式:正式发布 + 手动重跑。
|
|
4
|
+
# 手动重跑由 publish 步骤的 skip-existing 兜底,不会撞同名文件(PyPI "File already exists")。
|
|
5
|
+
on:
|
|
6
|
+
release:
|
|
7
|
+
types: [published]
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
permissions:
|
|
11
|
+
contents: read
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
# ───────────────────────────── Linux ─────────────────────────────
|
|
15
|
+
linux:
|
|
16
|
+
name: Build Linux wheels (${{ matrix.target }})
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
strategy:
|
|
19
|
+
fail-fast: false
|
|
20
|
+
matrix:
|
|
21
|
+
target: [x86_64, aarch64]
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@v4
|
|
24
|
+
|
|
25
|
+
# 宿主只需要 uv(跑 uvx twine check);构建在 manylinux 容器内完成,宿主 python 无关。
|
|
26
|
+
- name: Set up uv
|
|
27
|
+
uses: astral-sh/setup-uv@v5
|
|
28
|
+
|
|
29
|
+
- name: Build wheels (manylinux 2_17 container)
|
|
30
|
+
uses: PyO3/maturin-action@v1
|
|
31
|
+
with:
|
|
32
|
+
# 固定 maturin 版本:uv 生产 pin 同款(v1.14.1),避免 auto 拉新版本引入隐式变化。
|
|
33
|
+
maturin-version: v1.14.1
|
|
34
|
+
target: ${{ matrix.target }}
|
|
35
|
+
# 显式 manylinux 2_17 替代 auto:
|
|
36
|
+
# auto 时 action 不给 maturin 传 --manylinux,平台标签由 maturin 隐式计算;
|
|
37
|
+
# 显式 2_17 强制按 glibc 2.17 基线审计,不达标构建即失败(而非上传后被 PyPI 拒)。
|
|
38
|
+
# x86_64 -> quay.io/pypa/manylinux2014_x86_64
|
|
39
|
+
# aarch64 -> ghcr.io/rust-cross/manylinux2014-cross:aarch64(基于 pypa 镜像,自带 3.14t)
|
|
40
|
+
manylinux: 2_17
|
|
41
|
+
args: >-
|
|
42
|
+
--release
|
|
43
|
+
--locked
|
|
44
|
+
--out dist
|
|
45
|
+
--interpreter 3.14 3.14t
|
|
46
|
+
--compatibility pypi
|
|
47
|
+
# --locked:Cargo.lock 已提交,锁定依赖版本。
|
|
48
|
+
# --interpreter 3.14 3.14t:manylinux 容器自带 cp314/cp314t 且已在 PATH,无需任何 hack。
|
|
49
|
+
# --compatibility pypi:上传前预检,只允许 PyPI 接受的标签。
|
|
50
|
+
# 不再传 --features extension-module:Cargo.toml default feature 与 pyproject 已保证。
|
|
51
|
+
|
|
52
|
+
# 元数据预检(README 渲染、classifier 等),坏元数据在构建 job 就失败。
|
|
53
|
+
- name: Check wheel metadata
|
|
54
|
+
run: uvx twine check --strict dist/*
|
|
55
|
+
|
|
56
|
+
- name: Upload wheels
|
|
57
|
+
uses: actions/upload-artifact@v4
|
|
58
|
+
with:
|
|
59
|
+
name: wheels-linux-${{ matrix.target }}
|
|
60
|
+
path: dist
|
|
61
|
+
|
|
62
|
+
# ───────────────────────────── macOS ─────────────────────────────
|
|
63
|
+
macos:
|
|
64
|
+
name: Build macOS wheels (${{ matrix.target }})
|
|
65
|
+
runs-on: macos-latest
|
|
66
|
+
strategy:
|
|
67
|
+
fail-fast: false
|
|
68
|
+
matrix:
|
|
69
|
+
target: [x86_64, aarch64]
|
|
70
|
+
steps:
|
|
71
|
+
- uses: actions/checkout@v4
|
|
72
|
+
|
|
73
|
+
# 分架构替代 universal2:macos-latest 是 arm64,aarch64 原生构建、x86_64 跨编译。
|
|
74
|
+
# 多行安装 3.14 + 3.14t:macOS 上共存没有问题(Windows 才有同 minor 共存限制)。
|
|
75
|
+
- name: Set up Python 3.14 & 3.14t
|
|
76
|
+
uses: actions/setup-python@v6
|
|
77
|
+
with:
|
|
78
|
+
python-version: |
|
|
79
|
+
3.14
|
|
80
|
+
3.14t
|
|
81
|
+
|
|
82
|
+
- name: Set up uv
|
|
83
|
+
uses: astral-sh/setup-uv@v5
|
|
84
|
+
|
|
85
|
+
- name: Build wheels
|
|
86
|
+
uses: PyO3/maturin-action@v1
|
|
87
|
+
with:
|
|
88
|
+
maturin-version: v1.14.1
|
|
89
|
+
target: ${{ matrix.target }}
|
|
90
|
+
args: >-
|
|
91
|
+
--release
|
|
92
|
+
--locked
|
|
93
|
+
--out dist
|
|
94
|
+
--interpreter 3.14 3.14t
|
|
95
|
+
--compatibility pypi
|
|
96
|
+
# manylinux 输入在非 Linux 平台被 action 忽略;--compatibility pypi 对所有平台生效。
|
|
97
|
+
|
|
98
|
+
- name: Check wheel metadata
|
|
99
|
+
run: uvx twine check --strict dist/*
|
|
100
|
+
|
|
101
|
+
- name: Upload wheels
|
|
102
|
+
uses: actions/upload-artifact@v4
|
|
103
|
+
with:
|
|
104
|
+
name: wheels-macos-${{ matrix.target }}
|
|
105
|
+
path: dist
|
|
106
|
+
|
|
107
|
+
# ───────────────────────────── Windows ─────────────────────────────
|
|
108
|
+
windows:
|
|
109
|
+
name: Build Windows wheels (Python ${{ matrix.python-version }})
|
|
110
|
+
runs-on: windows-latest
|
|
111
|
+
strategy:
|
|
112
|
+
fail-fast: false
|
|
113
|
+
matrix:
|
|
114
|
+
# 3.14 与 3.14t 必须分 job:Windows 上同一 minor 的常规+free-threaded 解释器
|
|
115
|
+
# 共存于一个 setup-python 步骤会失败(python/cpython#127294)。
|
|
116
|
+
python-version: ["3.14", "3.14t"]
|
|
117
|
+
steps:
|
|
118
|
+
- uses: actions/checkout@v4
|
|
119
|
+
|
|
120
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
121
|
+
uses: actions/setup-python@v6
|
|
122
|
+
with:
|
|
123
|
+
python-version: ${{ matrix.python-version }}
|
|
124
|
+
architecture: x64
|
|
125
|
+
|
|
126
|
+
- name: Set up uv
|
|
127
|
+
uses: astral-sh/setup-uv@v5
|
|
128
|
+
|
|
129
|
+
- name: Build wheels
|
|
130
|
+
uses: PyO3/maturin-action@v1
|
|
131
|
+
with:
|
|
132
|
+
maturin-version: v1.14.1
|
|
133
|
+
target: x86_64
|
|
134
|
+
args: >-
|
|
135
|
+
--release
|
|
136
|
+
--locked
|
|
137
|
+
--out dist
|
|
138
|
+
--interpreter ${{ matrix.python-version }}
|
|
139
|
+
--compatibility pypi
|
|
140
|
+
|
|
141
|
+
- name: Check wheel metadata
|
|
142
|
+
run: uvx twine check --strict dist/*
|
|
143
|
+
|
|
144
|
+
- name: Upload wheels
|
|
145
|
+
uses: actions/upload-artifact@v4
|
|
146
|
+
with:
|
|
147
|
+
name: wheels-windows-${{ matrix.python-version }}
|
|
148
|
+
path: dist
|
|
149
|
+
|
|
150
|
+
# ───────────────────────────── sdist ─────────────────────────────
|
|
151
|
+
sdist:
|
|
152
|
+
name: Build source distribution
|
|
153
|
+
runs-on: ubuntu-latest
|
|
154
|
+
steps:
|
|
155
|
+
- uses: actions/checkout@v4
|
|
156
|
+
|
|
157
|
+
- name: Set up uv
|
|
158
|
+
uses: astral-sh/setup-uv@v5
|
|
159
|
+
|
|
160
|
+
- name: Build sdist
|
|
161
|
+
uses: PyO3/maturin-action@v1
|
|
162
|
+
with:
|
|
163
|
+
command: sdist
|
|
164
|
+
args: --out dist
|
|
165
|
+
# 宿主构建需要显式 rust-toolchain(action 文档要求)。
|
|
166
|
+
rust-toolchain: stable
|
|
167
|
+
|
|
168
|
+
- name: Check sdist metadata
|
|
169
|
+
run: uvx twine check --strict dist/*
|
|
170
|
+
|
|
171
|
+
- name: Upload sdist
|
|
172
|
+
uses: actions/upload-artifact@v4
|
|
173
|
+
with:
|
|
174
|
+
name: wheels-sdist
|
|
175
|
+
path: dist
|
|
176
|
+
|
|
177
|
+
# ───────────────────────────── wheel 实测 ─────────────────────────────
|
|
178
|
+
# 构建产物先在真实 runner 上安装并跑测试套件,通过才允许发布
|
|
179
|
+
# (pydantic-core test-builds-os / uv 构建后冒烟测试同款思路)。
|
|
180
|
+
test_wheels:
|
|
181
|
+
name: Test wheel on ${{ matrix.os }} (Python ${{ matrix.python-version }})
|
|
182
|
+
needs: [linux, macos, windows]
|
|
183
|
+
strategy:
|
|
184
|
+
fail-fast: false
|
|
185
|
+
matrix:
|
|
186
|
+
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
187
|
+
python-version: ["3.14", "3.14t"]
|
|
188
|
+
runs-on: ${{ matrix.os }}
|
|
189
|
+
steps:
|
|
190
|
+
- uses: actions/checkout@v4
|
|
191
|
+
|
|
192
|
+
- name: Set up uv & Python ${{ matrix.python-version }}
|
|
193
|
+
uses: astral-sh/setup-uv@v5
|
|
194
|
+
with:
|
|
195
|
+
enable-cache: true
|
|
196
|
+
python-version: ${{ matrix.python-version }}
|
|
197
|
+
|
|
198
|
+
# 装依赖(含项目 editable);下一步用 wheel 强制覆盖它。
|
|
199
|
+
- name: Install test dependencies
|
|
200
|
+
run: uv sync --group dev
|
|
201
|
+
|
|
202
|
+
- name: Download built wheels
|
|
203
|
+
uses: actions/download-artifact@v4
|
|
204
|
+
with:
|
|
205
|
+
pattern: wheels-*
|
|
206
|
+
merge-multiple: true
|
|
207
|
+
path: dist
|
|
208
|
+
|
|
209
|
+
# 只从 dist 装、不碰 PyPI;pip 自动选匹配本机 arch/python 的 wheel,
|
|
210
|
+
# 某平台缺对应 wheel 时此步失败 → 缺口在上传前暴露。
|
|
211
|
+
- name: Install wheel (no index)
|
|
212
|
+
run: uv pip install multiloop --no-index --no-deps --find-links dist --force-reinstall
|
|
213
|
+
|
|
214
|
+
# 冒烟:直接 import 扩展模块,跨编译/容器构建的坏产物在此暴露。
|
|
215
|
+
- name: Smoke test (extension import)
|
|
216
|
+
run: uv run python -c "import multiloop._multiloop_core as m; import multiloop; assert multiloop.__version__; print('ok:', m.__file__)"
|
|
217
|
+
|
|
218
|
+
# 完整测试套件跑在 wheel 上(addopts 自带 not slow)。
|
|
219
|
+
# free_threading 测试不再排除:CancelScope / CapacityLimiter 的并发
|
|
220
|
+
# bug 已修复,真 3.14t 上这 4 个测试现在必须真实运行并通过。
|
|
221
|
+
- name: Run test suite against installed wheel
|
|
222
|
+
run: uv run pytest -m "not slow"
|
|
223
|
+
|
|
224
|
+
# ───────────────────────────── 发布 ─────────────────────────────
|
|
225
|
+
publish:
|
|
226
|
+
name: Publish to PyPI
|
|
227
|
+
needs: [test_wheels, sdist]
|
|
228
|
+
runs-on: ubuntu-latest
|
|
229
|
+
permissions:
|
|
230
|
+
id-token: write
|
|
231
|
+
|
|
232
|
+
steps:
|
|
233
|
+
- uses: actions/checkout@v4
|
|
234
|
+
# 版本校验需要读 pyproject.toml。
|
|
235
|
+
|
|
236
|
+
- name: Set up uv
|
|
237
|
+
uses: astral-sh/setup-uv@v5
|
|
238
|
+
|
|
239
|
+
- name: Download all artifacts
|
|
240
|
+
uses: actions/download-artifact@v4
|
|
241
|
+
with:
|
|
242
|
+
pattern: wheels-*
|
|
243
|
+
merge-multiple: true
|
|
244
|
+
path: dist
|
|
245
|
+
|
|
246
|
+
# tag 与 pyproject 版本一致性校验;仅 tag 触发时执行,手动 dispatch 以 pyproject 为准。
|
|
247
|
+
- name: Check version matches tag (release only)
|
|
248
|
+
if: startsWith(github.ref, 'refs/tags/')
|
|
249
|
+
run: |
|
|
250
|
+
TAG_VERSION="${GITHUB_REF_NAME#v}"
|
|
251
|
+
PKG_VERSION="$(uv run python -c 'import tomllib; print(tomllib.load(open("pyproject.toml", "rb"))["project"]["version"])')"
|
|
252
|
+
test "$TAG_VERSION" = "$PKG_VERSION" || { echo "Version mismatch: tag=$TAG_VERSION, pyproject=$PKG_VERSION"; exit 1; }
|
|
253
|
+
|
|
254
|
+
# 逐 wheel 验证 zip 完整性。
|
|
255
|
+
- name: Verify wheel integrity (zip check)
|
|
256
|
+
run: for whl in dist/*.whl; do unzip -qt "$whl"; done
|
|
257
|
+
|
|
258
|
+
- name: Publish package to PyPI
|
|
259
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
260
|
+
with:
|
|
261
|
+
# 幂等重试:部分失败后重跑时,已上传的同名文件跳过而非报错。
|
|
262
|
+
# 构建期已有 --compatibility pypi + twine check + wheel 实测三道闸,
|
|
263
|
+
# skip-existing 只掩盖"文件名已存在"这一类无害冲突。
|
|
264
|
+
skip-existing: true
|