Skip to main content

osu-beatmap-preview-py

osu-beatmap-preview 的 Python 原生扩展。渲染器通过 PyO3 直接运行在 Python 进程内,不需要下载、配置或启动额外的 可执行文件。

当前为早期开发版本。Rust 渲染器使用上游 v1.3.1,固定到具体提交,以确保 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 发布。发布前需要:

  1. 在 GitHub 创建名为 pypi 的 environment;
  2. 在 PyPI 为该 GitHub 仓库配置 Trusted Publisher;
  3. 确认对应版本已经同时写入 Cargo.toml 和 pyproject.toml。

许可证

本项目采用 MIT License。上游渲染器同样采用 MIT License,版权归其贡献者所有。

Metadata

Release files for osu-beatmap-preview-py 0.1.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for osu-beatmap-preview-py 0.1.7
File Size Uploaded
osu_beatmap_preview_py-0.1.7.tar.gz 31.1 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for osu-beatmap-preview-py 0.1.7
File
osu_beatmap_preview_py-0.1.7-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
osu_beatmap_preview_py-0.1.7-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.7-cp310-abi3-manylinux_2_28_aarch64.whl CPython 3.10 abi3 Linux glibc 2.28+ ARM64 Details
osu_beatmap_preview_py-0.1.7-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
osu_beatmap_preview_py-0.1.7-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details

Total release size: 18.1 MB

Release files / osu_beatmap_preview_py-0.1.7.tar.gz

Download URL osu_beatmap_preview_py-0.1.7.tar.gz
Size 31.1 kB
Tags Source
SHA-256 checksum
How to use checksums
bf7b13a48d5957c14f26fc27a502edbcddb74abbf896b1227cca71995c60c225
BLAKE2b-256 checksum
How to use checksums
bafee88ad3a7c8c27913290f1fe3d8a199bad397a42bc9f41977207ab2f56a48
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 18, 2026.

Transparency log

Release files / osu_beatmap_preview_py-0.1.7-cp310-abi3-win_amd64.whl

Download URL osu_beatmap_preview_py-0.1.7-cp310-abi3-win_amd64.whl
Size 3.7 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
506cbb5723b776a9e83d3cc56ed0a765ca5878a21bbf3d24afbe56284e525051
BLAKE2b-256 checksum
How to use checksums
de45dc3eec5313ec855dafbd007328e3c47030eb8d0f5726981d121d66d0ae3e
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 18, 2026.

Transparency log

Release files / osu_beatmap_preview_py-0.1.7-cp310-abi3-manylinux_2_28_x86_64.whl

Download URL osu_beatmap_preview_py-0.1.7-cp310-abi3-manylinux_2_28_x86_64.whl
Size 3.8 MB
Tags CPython 3.10 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
a43053e1ceb7671ca7f4c2beef9685c4093d8556411b15653ad1ae4f16089d62
BLAKE2b-256 checksum
How to use checksums
3ab8256ca52083389c016e4e70d95469dad6739a5a43b690ae7e7b83989cdaa2
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 18, 2026.

Transparency log

Release files / osu_beatmap_preview_py-0.1.7-cp310-abi3-manylinux_2_28_aarch64.whl

Download URL osu_beatmap_preview_py-0.1.7-cp310-abi3-manylinux_2_28_aarch64.whl
Size 3.7 MB
Tags CPython 3.10 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
b8af638adc198b8cf47e5ef554181c13fe820b245181624f1fefc1d772aaf6a1
BLAKE2b-256 checksum
How to use checksums
de020169ce5e4ec7489ca0f998d7715509d7d3e64e2c61eb7f67605d7b24eb00
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 18, 2026.

Transparency log

Release files / osu_beatmap_preview_py-0.1.7-cp310-abi3-macosx_11_0_arm64.whl

Download URL osu_beatmap_preview_py-0.1.7-cp310-abi3-macosx_11_0_arm64.whl
Size 3.4 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
8d8700b65e46e82571f725a6dc455bb122fcda439905539d42da997f19317dce
BLAKE2b-256 checksum
How to use checksums
021515cc40b3fd51dfc773829c8201581856537943cd67ec02e721b25440f153
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 18, 2026.

Transparency log

Release files / osu_beatmap_preview_py-0.1.7-cp310-abi3-macosx_10_12_x86_64.whl

Download URL osu_beatmap_preview_py-0.1.7-cp310-abi3-macosx_10_12_x86_64.whl
Size 3.6 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
a0487dd74ea9b5c7bc06997a0906bddcc724246ab0454407333827c229c53e7e
BLAKE2b-256 checksum
How to use checksums
31c6acab4a29b6f64f9d9524bddcee7a14f235957f829a716e2ee970c0e73680
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 18, 2026.

Transparency log

Release history Release notifications | RSS feed

0.1.10

6 release files

0.1.9

6 release files

0.1.8

6 release files

This release

0.1.7 This release

6 release files

0.1.6

6 release files

0.1.5

6 release files

0.1.4

6 release files

0.1.3

6 release files

0.1.2

6 release files

0.1.1

6 release files

0.1.0

6 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page