ncm-api-py 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.
@@ -0,0 +1,15 @@
1
+ # 仓库内统一存 LF。Windows 上默认 core.autocrlf=true 会把 CRLF 提交进去,
2
+ # 导致 Linux CI 上的 `cargo fmt --check` / ruff 报格式错误,甚至影响 shell 步骤。
3
+ * text=auto eol=lf
4
+
5
+ # 二进制文件不要做任何换行或 diff 文本转换
6
+ *.pyd binary
7
+ *.dll binary
8
+ *.so binary
9
+ *.dylib binary
10
+ *.png binary
11
+ *.jpg binary
12
+ *.ico binary
13
+
14
+ # Cargo.lock 是生成物,折叠 diff 噪音
15
+ Cargo.lock -diff linguist-generated
@@ -0,0 +1,96 @@
1
+ # 持续集成:在 push / PR 上做格式、静态检查与构建验证。
2
+ #
3
+ # 这里刻意不做任何发布动作。发布由 Release.yml 负责,只在
4
+ # 「发布 Release」或手动触发时执行,避免同一份产物被推两次。
5
+
6
+ name: CI
7
+
8
+ on:
9
+ push:
10
+ branches: [main, master]
11
+ pull_request:
12
+ workflow_dispatch:
13
+
14
+ permissions:
15
+ contents: read
16
+
17
+ env:
18
+ CARGO_TERM_COLOR: always
19
+
20
+ jobs:
21
+ lint:
22
+ name: fmt / clippy / ruff
23
+ runs-on: ubuntu-latest
24
+ steps:
25
+ - uses: actions/checkout@v4
26
+ - uses: actions/setup-python@v5
27
+ with:
28
+ python-version: "3.14"
29
+ - uses: dtolnay/rust-toolchain@stable
30
+ with:
31
+ components: rustfmt, clippy
32
+ - name: cargo fmt
33
+ run: cargo fmt --all --check
34
+ - name: cargo clippy
35
+ run: cargo clippy --all-targets --features extension-module -- -D warnings
36
+ - uses: astral-sh/setup-uv@v7
37
+ - name: ruff
38
+ run: uvx ruff check
39
+
40
+ build-linux:
41
+ name: build wheel (linux ${{ matrix.target }})
42
+ runs-on: ubuntu-latest
43
+ strategy:
44
+ fail-fast: false
45
+ matrix:
46
+ target: [x86_64, aarch64]
47
+ steps:
48
+ - uses: actions/checkout@v4
49
+ - uses: actions/setup-python@v5
50
+ with:
51
+ python-version: "3.14"
52
+ - name: Build wheel
53
+ uses: PyO3/maturin-action@v1
54
+ with:
55
+ target: ${{ matrix.target }}
56
+ # auto(=manylinux2014) 的 cross 镜像 GCC 太老,ring 的 ARM 汇编会编译失败
57
+ manylinux: manylinux_2_28
58
+ args: --release --out dist
59
+ - name: Check wheel
60
+ run: |
61
+ ls -l dist
62
+ ls dist/*abi3*.whl
63
+ # aarch64 是交叉编译产物,装不进 x86_64 runner,只校验产物名
64
+ if [ "${{ matrix.target }}" = "x86_64" ]; then
65
+ python -m pip install --force-reinstall --no-index --find-links dist ncm-api-py
66
+ python -c "import ncm_api_py; print('import OK:', ncm_api_py.__file__)"
67
+ fi
68
+
69
+ build-native:
70
+ name: build wheel (${{ matrix.runner }}/${{ matrix.target }})
71
+ runs-on: ${{ matrix.runner }}
72
+ strategy:
73
+ fail-fast: false
74
+ matrix:
75
+ include:
76
+ - runner: windows-latest
77
+ target: x64
78
+ - runner: macos-latest
79
+ target: aarch64
80
+ steps:
81
+ - uses: actions/checkout@v4
82
+ - uses: actions/setup-python@v5
83
+ with:
84
+ python-version: "3.14"
85
+ - name: Build wheel
86
+ uses: PyO3/maturin-action@v1
87
+ with:
88
+ target: ${{ matrix.target }}
89
+ args: --release --out dist
90
+ - name: Check wheel
91
+ shell: bash
92
+ run: |
93
+ ls -l dist
94
+ ls dist/*abi3*.whl
95
+ python -m pip install --force-reinstall --no-index --find-links dist ncm-api-py
96
+ python -c "import ncm_api_py; print('import OK:', ncm_api_py.__file__)"
@@ -0,0 +1,205 @@
1
+ # 发布流程:在 GitHub 上创建(发布)Release 时构建各平台 wheel 并发布到 PyPI。
2
+ #
3
+ # 使用 PyPI Trusted Publishing(OIDC),不需要在仓库里存任何 token。
4
+ # 首次发布前需要在 PyPI 配置一次 Trusted Publisher:
5
+ # https://pypi.org/manage/account/publishing/
6
+ # PyPI Project Name : ncm-api-py
7
+ # Owner : hyouryo
8
+ # Repository name : ncm-api-py
9
+ # Workflow name : Release.yml
10
+ # Environment name : pypi
11
+ # 若 ncm-api-py 在 PyPI 上还不存在,请填 "pending publisher",首次发布后会自动转为正式项目。
12
+ #
13
+ # 触发方式:
14
+ # 1. 发布 Release(release: published)—— 构建并上传 PyPI。
15
+ # 2. 手动 workflow_dispatch —— 默认只构建、不上传(排练);勾选 publish 才会上传。
16
+ # 想完整验证「上传」这一步,更推荐用「草稿 Release」:草稿不会触发任何运行,
17
+ # 点 Publish 时才走路径 1。
18
+
19
+ name: Release
20
+
21
+ on:
22
+ release:
23
+ types: [published]
24
+ workflow_dispatch:
25
+ inputs:
26
+ publish:
27
+ description: "真的上传到 PyPI(默认关闭,只做构建排练)"
28
+ type: boolean
29
+ default: false
30
+
31
+ permissions:
32
+ contents: read
33
+
34
+ jobs:
35
+ # ---------- 版本号校验:挡住「tag 与 Cargo.toml 不一致」就发布 ----------
36
+ # 版本号唯一来源是 Cargo.toml 的 version(pyproject.toml 用的是 dynamic version),
37
+ # maturin 不看 git tag。所以 tag 写错不会有任何报错,只会静默发出错误的版本号,
38
+ # 而 PyPI 上那个版本号一旦被占用就再也改不了。这里先检查,避免白发一轮。
39
+ version:
40
+ name: tag 与版本号一致
41
+ runs-on: ubuntu-latest
42
+ steps:
43
+ - uses: actions/checkout@v4
44
+ - name: Check tag matches Cargo.toml version
45
+ run: |
46
+ set -euo pipefail
47
+ have="$(sed -n 's/^version[[:space:]]*=[[:space:]]*"\(.*\)".*/\1/p' Cargo.toml | head -1)"
48
+ tag="${{ github.event.release.tag_name }}"
49
+ if [ -z "$tag" ]; then
50
+ echo "手动触发(无 tag),当前版本为 $have —— 只做构建排练,跳过校验"
51
+ exit 0
52
+ fi
53
+ want="${tag#v}" # 允许 tag 带或不带 v 前缀
54
+ echo "tag=$tag Cargo.toml=$have"
55
+ if [ "$want" != "$have" ]; then
56
+ echo "::error::tag ($tag) 与 Cargo.toml 的 version ($have) 不一致。"
57
+ echo "::error::请把 Cargo.toml 改成 \"$want\" 后重新提交,再发布 Release。"
58
+ exit 1
59
+ fi
60
+ echo "一致:$have"
61
+
62
+ # ---------- 各平台构建 wheel ----------
63
+ linux:
64
+ runs-on: ubuntu-latest
65
+ strategy:
66
+ matrix:
67
+ target: [x86_64, aarch64]
68
+ steps:
69
+ - uses: actions/checkout@v4
70
+ - uses: actions/setup-python@v5
71
+ with:
72
+ python-version: "3.14"
73
+ - name: Build wheels
74
+ uses: PyO3/maturin-action@v1
75
+ with:
76
+ target: ${{ matrix.target }}
77
+ args: --release --out dist
78
+ sccache: "true"
79
+ # 必须是 manylinux_2_28 而不是 auto(=manylinux2014):那个 cross 镜像基于
80
+ # CentOS 7 / GCC 4.8,不会预定义 __ARM_ARCH,导致 ring 的 ARM 汇编编译失败。
81
+ # 2_28 的 GCC 足够新;代价是 glibc 下限从 2.17 提到 2.28
82
+ # (CentOS 8+ / Debian 10+ / Ubuntu 20.04+)。
83
+ manylinux: manylinux_2_28
84
+ - uses: actions/upload-artifact@v4
85
+ with:
86
+ name: wheels-linux-${{ matrix.target }}
87
+ path: dist
88
+
89
+ musllinux:
90
+ runs-on: ubuntu-latest
91
+ strategy:
92
+ matrix:
93
+ target: [x86_64, aarch64]
94
+ steps:
95
+ - uses: actions/checkout@v4
96
+ - uses: actions/setup-python@v5
97
+ with:
98
+ python-version: "3.14"
99
+ - name: Build wheels
100
+ uses: PyO3/maturin-action@v1
101
+ with:
102
+ target: ${{ matrix.target }}
103
+ args: --release --out dist
104
+ sccache: "true"
105
+ manylinux: musllinux_1_2
106
+ - uses: actions/upload-artifact@v4
107
+ with:
108
+ name: wheels-musllinux-${{ matrix.target }}
109
+ path: dist
110
+
111
+ windows:
112
+ runs-on: windows-latest
113
+ strategy:
114
+ matrix:
115
+ target: [x64, x86]
116
+ steps:
117
+ - uses: actions/checkout@v4
118
+ - uses: actions/setup-python@v5
119
+ with:
120
+ # abi3 只出一个 wheel,不再需要多版本解释器
121
+ python-version: "3.14"
122
+ architecture: ${{ matrix.target }}
123
+ - name: Build wheels
124
+ uses: PyO3/maturin-action@v1
125
+ with:
126
+ target: ${{ matrix.target }}
127
+ args: --release --out dist
128
+ sccache: "true"
129
+ - uses: actions/upload-artifact@v4
130
+ with:
131
+ name: wheels-windows-${{ matrix.target }}
132
+ path: dist
133
+
134
+ macos:
135
+ runs-on: macos-latest
136
+ strategy:
137
+ matrix:
138
+ target: [x86_64, aarch64]
139
+ steps:
140
+ - uses: actions/checkout@v4
141
+ - uses: actions/setup-python@v5
142
+ with:
143
+ python-version: "3.14"
144
+ - name: Build wheels
145
+ uses: PyO3/maturin-action@v1
146
+ with:
147
+ target: ${{ matrix.target }}
148
+ args: --release --out dist
149
+ sccache: "true"
150
+ - uses: actions/upload-artifact@v4
151
+ with:
152
+ name: wheels-macos-${{ matrix.target }}
153
+ path: dist
154
+
155
+ sdist:
156
+ runs-on: ubuntu-latest
157
+ steps:
158
+ - uses: actions/checkout@v4
159
+ - name: Build sdist
160
+ uses: PyO3/maturin-action@v1
161
+ with:
162
+ command: sdist
163
+ args: --out dist
164
+ - uses: actions/upload-artifact@v4
165
+ with:
166
+ name: wheels-sdist
167
+ path: dist
168
+
169
+ # ---------- 发布到 PyPI ----------
170
+ release:
171
+ name: Publish to PyPI
172
+ runs-on: ubuntu-latest
173
+ # 只有两种情况才进入本 job(即真正发布):
174
+ # 1. 发布了 Release(release: published);
175
+ # 2. 手动触发时勾选了 publish。
176
+ # 手动触发不勾 publish = 只跑上面 5 个构建 job 的排练,不会碰 PyPI。
177
+ if: ${{ github.event_name == 'release' || inputs.publish }}
178
+ needs: [version, linux, musllinux, windows, macos, sdist]
179
+ environment:
180
+ name: pypi
181
+ url: https://pypi.org/p/ncm-api-py
182
+ permissions:
183
+ # Trusted Publishing 必需:用 OIDC 换取 PyPI 的短期凭据
184
+ id-token: write
185
+ # 用于生成构建来源证明(attestation)
186
+ attestations: write
187
+ contents: read
188
+ steps:
189
+ - uses: actions/download-artifact@v4
190
+ with:
191
+ pattern: wheels-*
192
+ merge-multiple: true
193
+ path: dist
194
+ - name: List collected artifacts
195
+ run: ls -l dist
196
+ # 能走到这里就说明确实要发布,所以这两步不需要额外条件
197
+ - name: Generate artifact attestation
198
+ uses: actions/attest-build-provenance@v2
199
+ with:
200
+ subject-path: "dist/*"
201
+ - name: Publish to PyPI
202
+ uses: PyO3/maturin-action@v1
203
+ with:
204
+ command: upload
205
+ args: --non-interactive --skip-existing dist/*
@@ -0,0 +1,79 @@
1
+ /target
2
+
3
+ # Byte-compiled / optimized / DLL files
4
+ __pycache__/
5
+ .pytest_cache/
6
+ *.py[cod]
7
+
8
+ # C extensions
9
+ *.so
10
+
11
+ # Distribution / packaging
12
+ .Python
13
+ .venv/
14
+ env/
15
+ bin/
16
+ build/
17
+ develop-eggs/
18
+ dist/
19
+ eggs/
20
+ lib/
21
+ lib64/
22
+ parts/
23
+ sdist/
24
+ var/
25
+ include/
26
+ man/
27
+ venv/
28
+ *.egg-info/
29
+ .installed.cfg
30
+ *.egg
31
+
32
+ # Installer logs
33
+ pip-log.txt
34
+ pip-delete-this-directory.txt
35
+ pip-selfcheck.json
36
+
37
+ # Unit test / coverage reports
38
+ htmlcov/
39
+ .tox/
40
+ .coverage
41
+ .cache
42
+ nosetests.xml
43
+ coverage.xml
44
+
45
+ # Translations
46
+ *.mo
47
+
48
+ # Mr Developer
49
+ .mr.developer.cfg
50
+ .project
51
+ .pydevproject
52
+
53
+ # Rope
54
+ .ropeproject
55
+
56
+ # Django stuff:
57
+ *.log
58
+ *.pot
59
+
60
+ .DS_Store
61
+
62
+ # Sphinx documentation
63
+ docs/_build/
64
+
65
+ # PyCharm
66
+ .idea/
67
+
68
+ # VSCode
69
+ .vscode/
70
+
71
+ # Pyenv
72
+ .python-version
73
+
74
+ # 类型检查 / 格式化工具的缓存
75
+ .mypy_cache/
76
+ .ruff_cache/
77
+ .uvcache/
78
+ .uvtools/
79
+ .uvbin/