osu-beatmap-preview-py
osu-beatmap-preview 的
Python 原生扩展。渲染器通过 PyO3 直接运行在 Python 进程内,不需要下载、配置或启动额外的
可执行文件。
当前为早期开发版本。Rust 核心固定到经过绑定测试的具体提交,以确保 Python wheel 在各平台使用相同的渲染行为。
安装
pip install osu-beatmap-preview-py
PyPI 发布后,pip 会为受支持的平台安装预编译 wheel,不要求用户安装 Rust。没有预编译 wheel 的平台从源码安装时仍需要 Rust 和 C++ 工具链。
使用
from osu_beatmap_preview import generate_preview_async
result = await generate_preview_async(
4498112,
format="gif",
mods="hd+hr",
times="preview+60",
duration_time=8,
fps=30,
scale=1.5,
)
print(result["preview-img"])
generate_preview() 是同步接口,适合脚本;NoneBot、FastAPI 等异步应用应使用
generate_preview_async(),避免阻塞事件循环。
convert 仅用于将 osu!standard 谱面转换成 taiko、ctb 或 mania。原生非 standard
谱面不要传入 convert。
times 使用 + 分隔多个秒数,也支持 preview;duration_time 控制 GIF 片段或 MP4
区间时长。config 可传配置文件路径或内联 JSON/YAML,scale 用于临时覆盖输出倍率。
异步取消与并发
上游 Rust API 当前是同步接口,没有提供取消令牌。取消 generate_preview_async() 所在的
Python task 不会中止已经开始的原生渲染;Bot 集成时应使用 semaphore 限制并发。若需要真正的
超时中止,应先在上游 library API 增加协作式取消能力。
本地开发
uv sync
uv run maturin develop
uv run pytest
发布
推送 v* tag 后,GitHub Actions 会构建 Windows、Linux 和 macOS wheel,并通过 PyPI
Trusted Publishing 发布。发布前需要:
- 在 GitHub 创建名为
pypi的 environment; - 在 PyPI 为该 GitHub 仓库配置 Trusted Publisher;
- 确认对应版本已经同时写入
Cargo.toml和pyproject.toml。
许可证
本项目采用 MIT License。上游渲染器同样采用 MIT License,版权归其贡献者所有。
Metadata
Release files for osu-beatmap-preview-py 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| osu_beatmap_preview_py-0.1.5.tar.gz | 30.9 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| osu_beatmap_preview_py-0.1.5-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details |
| osu_beatmap_preview_py-0.1.5-cp310-abi3-manylinux_2_28_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.28+ x86-64 | Details |
| osu_beatmap_preview_py-0.1.5-cp310-abi3-manylinux_2_28_aarch64.whl | CPython 3.10 | abi3 | Linux glibc 2.28+ ARM64 | Details |
| osu_beatmap_preview_py-0.1.5-cp310-abi3-macosx_11_0_arm64.whl | CPython 3.10 | abi3 | macOS 11.0+ ARM64 | Details |
| osu_beatmap_preview_py-0.1.5-cp310-abi3-macosx_10_12_x86_64.whl | CPython 3.10 | abi3 | macOS 10.12+ x86-64 | Details |
Total release size: 16.5 MB
Release files / osu_beatmap_preview_py-0.1.5.tar.gz
| Download URL | osu_beatmap_preview_py-0.1.5.tar.gz |
|---|---|
| Size | 30.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d798147e65f057aff803f59c8fe30fa77663f29c9e8a5628a742ff480a4a69da
|
|
BLAKE2b-256 checksum How to use checksums |
7f0727b7d262fcf7c3c8a5d375a094f0f86951822c0e196da1621eb46d7f659e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 4, 2026.
Transparency logRelease files / osu_beatmap_preview_py-0.1.5-cp310-abi3-win_amd64.whl
| Download URL | osu_beatmap_preview_py-0.1.5-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
fb2bc9c7e01ff17db2b26063f8eba831c7c482c325fd3d824ba2e968b8876dca
|
|
BLAKE2b-256 checksum How to use checksums |
9cb1dd1f55dce78de55fd2b9bbbafbe43de1de272d8931e3c186e10bab6672b0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 4, 2026.
Transparency logRelease files / osu_beatmap_preview_py-0.1.5-cp310-abi3-manylinux_2_28_x86_64.whl
| Download URL | osu_beatmap_preview_py-0.1.5-cp310-abi3-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 3.5 MB |
| Tags | CPython 3.10 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
584ec10a6808fb33b2cc4781a141c9bdf68a42f5270e9d74c98aa8bbea75d37c
|
|
BLAKE2b-256 checksum How to use checksums |
84229c978fb2cb15e8a0b5a9fea06f690564190c1d769c2dfbd58b239de37ea8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 4, 2026.
Transparency logRelease files / osu_beatmap_preview_py-0.1.5-cp310-abi3-manylinux_2_28_aarch64.whl
| Download URL | osu_beatmap_preview_py-0.1.5-cp310-abi3-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 3.4 MB |
| Tags | CPython 3.10 Linux glibc 2.28+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
bc6037e590fc9d2ca068288086073bf1db4d7feccd9e527ff22a581a8937ad23
|
|
BLAKE2b-256 checksum How to use checksums |
23a66eb03fd7d291fbceb265d2940b6f2b71a0b3c63c8bebe5fb978e3e58c50f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 4, 2026.
Transparency logRelease files / osu_beatmap_preview_py-0.1.5-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | osu_beatmap_preview_py-0.1.5-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 3.1 MB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
a4c6c19e53df14b37b6ea7ef05e1c82ea3cfd5c7a01db0db14c7776be69610a9
|
|
BLAKE2b-256 checksum How to use checksums |
db9e1f6ac657ffbeb2e59595acb88d282225a2ac55c9b92b5b7dff77c002863d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 4, 2026.
Transparency logRelease files / osu_beatmap_preview_py-0.1.5-cp310-abi3-macosx_10_12_x86_64.whl
| Download URL | osu_beatmap_preview_py-0.1.5-cp310-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 3.2 MB |
| Tags | CPython 3.10 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
ecc1f52b251e04eab08b667420d1a035aec92a3c5ac7c6fa923da342b825232a
|
|
BLAKE2b-256 checksum How to use checksums |
9a279f1404e9c5844270f21b14a0c634768e07f4540ed63caf8cf0dd6d9684f8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 4, 2026.
Transparency log