A Python wrapper for osu! tools using pythonnet
Project description
osu-tools-py
A high-performance Python wrapper for ppy/osu-tools, powered by pythonnet.
This library allows you to calculate Performance Points (PP), Star Ratings (SR), and other difficulty attributes for osu! beatmaps directly from Python. It embeds the official C# DLLs (compiled from osu!lazer), ensuring results are identical to the official game algorithms.
Features:
- 🚀 Accurate: Uses the actual C# code from osu!lazer for calculations.
- 📦 Batteries Included: Comes with pre-compiled DLLs (no need to compile C# yourself).
- 🖥️ Cross-Platform: Supports Windows, Linux, and macOS (Intel & Apple Silicon/M1/M2).
- 🧩 Type Safe: Fully typed Python API with data classes.
📋 Prerequisites
Before installing the Python package, you must have the .NET 8 Runtime installed on your system.
- Download .NET 8.0 Runtime
- Note: You only need the "Run console apps" version (Runtime); the SDK is not required for usage.
📦 Installation
pip install osu-tools-py
🚀 Quick Start
1. Calculate osu!stable PP
To get PP values that match the official osu! website (osu!stable), you must follow two rules:
- Add the "CL" (Classic) mod to your mod list.
- Provide a
legacy_total_score(any value > 0).
from osu_tools import OsuCalculator
# Initialize (loads .NET runtime)
calc = OsuCalculator()
# Example: Calculate Max PP for HDDT on Standard Mode
result = calc.calculate(
file_path="beatmaps/12345.osu",
mode=0,
# Rule 1: Always include "CL" for Stable calculations
mods=["HD", "DT", "CL"],
acc=100.0,
# Rule 2: Provide a legacy score > 0 to enable Stable physics/scoring
legacy_total_score=1000000
)
if result.is_success:
print(f"Stars: {result.stars:.2f}")
print(f"PP: {result.pp:.2f}")
print(f"Aim: {result.pp_aim:.2f}")
print(f"Speed: {result.pp_speed:.2f}")
else:
print(f"Error: {result.error}")
2. Calculate Real Score (from Replay/API)
When calculating a specific score for osu!stable, pass the hit statistics and ensure you include the Stable compatibility flags.
# Real stats from a score
stats = {
'great': 450,
'ok': 12,
'meh': 1,
'miss': 2
}
result = calc.calculate(
file_path="beatmaps/12345.osu",
mode=0,
mods=["HD", "CL"], # Don't forget CL!
combo=850,
statistics=stats,
legacy_total_score=1000000 # Required for Stable logic
)
print(f"Real PP: {result.pp:.2f}")
print(f"Real PPAcc: {result.pp_acc:.2f}") # PP from Accuracy
Lazer Calculation Example
If you want to calculate PP for the Lazer scoring system (where slider tails affect accuracy):
# Lazer calculation example
lazer_stats = {
'great': 450,
'ok': 10,
'miss': 5,
'slider_tail_hit': 200, # Lazer specific stat
'large_tick_hit': 50 # Lazer specific stat
}
result = calc.calculate(
file_path="beatmaps/12345.osu",
mode=0,
mods=[],
combo=800,
statistics=lazer_stats,
)
Supported Inputs
- Mods: Supports list of strings
["HD", "DT"], list of dicts[{"acronym": "HD"}], or objects. - Modes:
0: osu! (Standard)1: osu!taiko2: osu!catch3: osu!mania
Return Data
The function returns a CalculationResult object:
@dataclass
class CalculationResult:
mode: int
stars: float
pp: float
pp_aim: float
pp_speed: float
pp_acc: float
pp_flashlight: float
max_combo: int
error: Optional[str]
# ...
🛠️ Building from Source
If you want to modify the C# logic or build the wheels yourself:
-
Requirements:
- Python 3.10+
- .NET 8.0 SDK
uv(Python package manager)
-
Clone:
git clone --recursive https://github.com/yaowan233/osu-tools-py.git cd osu-tools-py
-
Build: The project uses GitHub Actions for matrix builds (Windows/Linux/macOS), but you can build locally:
# 1. Compile C# DLLs cd osu-tools/PerformanceCalculator dotnet publish -c Release -o ../../src/osu_tools/lib # 2. Build Python Wheel cd ../.. uv build
⚠️ Troubleshooting
-
RuntimeError: Failed to create a default .NET runtime:- Ensure you installed .NET 8 Runtime.
- On Linux/macOS, ensure
dotnetis in your PATH.
-
PP seems lower than official site:
- Did you add
"CL"to your mods list? - Did you pass
legacy_total_score=1000000?
- Did you add
📄 License
This project is licensed under the MIT License. Based on ppy/osu-tools (MIT) and pythonnet (MIT).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file osu_tools_py-0.1.2-py3-none-win_amd64.whl.
File metadata
- Download URL: osu_tools_py-0.1.2-py3-none-win_amd64.whl
- Upload date:
- Size: 31.3 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d9cb485cad2d1063e0faa90eb13177c5b2e84489ec9d9bdaf5bbc45fc1b8f3f
|
|
| MD5 |
297ed4251a39e15532a323b74d080371
|
|
| BLAKE2b-256 |
7e5ae0e15719e552f8417a3c439727a61b741ef8f0e6553ae1380fdd9a97fc70
|
Provenance
The following attestation bundles were made for osu_tools_py-0.1.2-py3-none-win_amd64.whl:
Publisher:
release.yml on yaowan233/osu-tools-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
osu_tools_py-0.1.2-py3-none-win_amd64.whl -
Subject digest:
3d9cb485cad2d1063e0faa90eb13177c5b2e84489ec9d9bdaf5bbc45fc1b8f3f - Sigstore transparency entry: 771921841
- Sigstore integration time:
-
Permalink:
yaowan233/osu-tools-py@288c1aae1d2db098e6e1d14b9c40dc47d7a15c5c -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/yaowan233
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@288c1aae1d2db098e6e1d14b9c40dc47d7a15c5c -
Trigger Event:
push
-
Statement type:
File details
Details for the file osu_tools_py-0.1.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: osu_tools_py-0.1.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 36.5 MB
- Tags: Python 3, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
09d5a25bde8d1865501e7a1998ecfbf900918eb917e79fc19b1fc82231b79f2c
|
|
| MD5 |
f2effe133291ba5775767201cc25bbe3
|
|
| BLAKE2b-256 |
9914f722bfc8c731efa0d85363dfda1de70be4d381d9b6411ed5d9a02c969f49
|
Provenance
The following attestation bundles were made for osu_tools_py-0.1.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on yaowan233/osu-tools-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
osu_tools_py-0.1.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
09d5a25bde8d1865501e7a1998ecfbf900918eb917e79fc19b1fc82231b79f2c - Sigstore transparency entry: 771921846
- Sigstore integration time:
-
Permalink:
yaowan233/osu-tools-py@288c1aae1d2db098e6e1d14b9c40dc47d7a15c5c -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/yaowan233
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@288c1aae1d2db098e6e1d14b9c40dc47d7a15c5c -
Trigger Event:
push
-
Statement type:
File details
Details for the file osu_tools_py-0.1.2-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: osu_tools_py-0.1.2-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 38.9 MB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f76400ab35972959cab1978fd23381817feecfcc936b07f0f3dbce5c8d3db6d8
|
|
| MD5 |
ddcc355f3d7d5db98e38f4c3b07dee50
|
|
| BLAKE2b-256 |
d03b3f86a1b906312ea4e838d71dd8436be0b1795036c37fe5f8aaea1ab2276b
|
Provenance
The following attestation bundles were made for osu_tools_py-0.1.2-py3-none-macosx_11_0_arm64.whl:
Publisher:
release.yml on yaowan233/osu-tools-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
osu_tools_py-0.1.2-py3-none-macosx_11_0_arm64.whl -
Subject digest:
f76400ab35972959cab1978fd23381817feecfcc936b07f0f3dbce5c8d3db6d8 - Sigstore transparency entry: 771921853
- Sigstore integration time:
-
Permalink:
yaowan233/osu-tools-py@288c1aae1d2db098e6e1d14b9c40dc47d7a15c5c -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/yaowan233
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@288c1aae1d2db098e6e1d14b9c40dc47d7a15c5c -
Trigger Event:
push
-
Statement type:
File details
Details for the file osu_tools_py-0.1.2-py3-none-macosx_10_15_x86_64.whl.
File metadata
- Download URL: osu_tools_py-0.1.2-py3-none-macosx_10_15_x86_64.whl
- Upload date:
- Size: 39.3 MB
- Tags: Python 3, macOS 10.15+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4579b1f5e19d449ddfdf95442f19025b8755b07cdb9b8efa0dae03ba0e6a9d39
|
|
| MD5 |
fd7ec520e256345ef9d39451d7a24a1f
|
|
| BLAKE2b-256 |
3c7f6f1f53d810739303bcb5e57e2bfd2e4ec4d6570988f113e0241cd4f04b4c
|
Provenance
The following attestation bundles were made for osu_tools_py-0.1.2-py3-none-macosx_10_15_x86_64.whl:
Publisher:
release.yml on yaowan233/osu-tools-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
osu_tools_py-0.1.2-py3-none-macosx_10_15_x86_64.whl -
Subject digest:
4579b1f5e19d449ddfdf95442f19025b8755b07cdb9b8efa0dae03ba0e6a9d39 - Sigstore transparency entry: 771921843
- Sigstore integration time:
-
Permalink:
yaowan233/osu-tools-py@288c1aae1d2db098e6e1d14b9c40dc47d7a15c5c -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/yaowan233
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@288c1aae1d2db098e6e1d14b9c40dc47d7a15c5c -
Trigger Event:
push
-
Statement type: