Skip to main content

A robust, type-safe Python wrapper for the Ludusavi game backup tool.

Project description

pyludusavi

A robust, type-safe Python wrapper for the Ludusavi CLI.

Features

  • Broad CLI Coverage: Supports the core Ludusavi subcommands and commonly used flags.
  • Linux-First: Native support for both local binaries and Flatpak.
  • Type-Safe: Comprehensive TypedDict models for all JSON outputs (Python 3.12+).
  • Dual-Mode Execution: Transparently handles binary vs. Flatpak command prefixing.
  • TDD-Backed: High-quality implementation with an extensive regression suite.

Setup

For local development, use the project wrapper so virtual environments and tool caches stay outside Dropbox:

source .envrc
./run.sh uv sync

Run validation through the same wrapper:

./run.sh uv run ruff check .
./run.sh uv run ty check src/
./run.sh uv run pytest

Installation

Use uv when adding the package to another Python project:

uv add pyludusavi

Quick Start

Basic Initialization

The wrapper automatically discovers Ludusavi via PATH or Flatpak.

from pyludusavi import Ludusavi

lud = Ludusavi()
print(f"Ludusavi version: {lud.version()}")

Backing Up Games

Perform a preview scan or a full backup.

# Preview a backup for a specific game
result = lud.backup(games=["The Witcher 3"], preview=True)

# Access typed data
for name, game in result.data["games"].items():
    print(f"Game: {name}, Status: {game['change']}")

Searching for Games

Use Steam IDs or fuzzy matching to find games in the manifest.

# Find by Steam ID
result = lud.find(steam_id="292030")

# Use fuzzy matching
result = lud.find(games=["Witcher"], fuzzy=True)

Advanced Usage

Flatpak Support

If you have Ludusavi installed via Flatpak, pyludusavi detects it automatically. You can also specify a custom binary path or Flatpak ID:

lud = Ludusavi(explicit_path="/usr/bin/ludusavi")
lud = Ludusavi(flatpak_id="com.github.mtkennerly.ludusavi")

Custom Config Directory

lud = Ludusavi(config_dir="/home/user/my-ludusavi-config")

Bulk API

For performance-critical bulk operations, use the native api subcommand:

payload = {
    "requests": [
        {"kind": "backup", "games": ["Game 1"]},
        {"kind": "backup", "games": ["Game 2"]}
    ]
}
lud.bulk_api(payload)

Cloud Sync

Use the upload/download helpers with the same common options exposed by the CLI.

lud.cloud_upload(games=["The Witcher 3"], local="/backups", cloud="/cloud", preview=True)
lud.cloud_download(games=["The Witcher 3"], force=True)

Wrap Game Launch

Ludusavi requires either a direct game name or launcher inference when wrapping a command.

lud.wrap(["./game.exe", "--windowed"], name="The Witcher 3")
lud.wrap(["steam", "-applaunch", "292030"], infer="steam", force=True)

Game Aliases

add_game_alias() updates Ludusavi's customGames configuration using only the Python standard library. It writes the updated config as JSON, which Ludusavi can read as YAML, but this does not preserve existing comments or formatting in config.yaml.

Error Handling

  • LudusaviNotFoundError: Raised if the executable or Flatpak isn't found.
  • LudusaviExecutionError: Raised if the process exits with a non-zero code.
  • LudusaviContractError: Raised if the CLI output is malformed or non-JSON when expected.

Dependency Requirements

  • Python 3.12+
  • uv
  • Ludusavi v0.31.0+
  • pytest, pytest-cov, ruff, and ty for local development

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyludusavi-0.2.2.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyludusavi-0.2.2-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

Details for the file pyludusavi-0.2.2.tar.gz.

File metadata

  • Download URL: pyludusavi-0.2.2.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pyludusavi-0.2.2.tar.gz
Algorithm Hash digest
SHA256 d4f366ec7eab3006af01bb4c30bff24e20ff2ee41fd97f05cdb95b233d934e6b
MD5 8dcb6c093998dd4ed1e18c4cfe3435bf
BLAKE2b-256 cc1190b5ad1a690d7f52b0c1da0d220ab307c17b69a97a4860b3ad8ed19f4c98

See more details on using hashes here.

File details

Details for the file pyludusavi-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: pyludusavi-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 13.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pyludusavi-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a438c2667618d54a7450864101f594b48b8040a1c57a36da88d2d65b98a1e8b2
MD5 545f374ff622e11bd2c759ff95e89eaf
BLAKE2b-256 5d06dca6698b0ecec14c43bf26c380c2d70a6281b73b060be8ade48ba753a6c4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page