Metadata-Version: 2.4
Name: pyupdator
Version: 0.1.1
Summary: Delta updater for games (Torrent and HTTP Zip support)
Author: pyupdator
License: MIT
Keywords: delta,updater,game,torrent,http,zip,cdc
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Operating System :: OS Independent
Classifier: Topic :: System :: Software Distribution
Classifier: Topic :: Utilities
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: torrentfile
Requires-Dist: libtorrent
Requires-Dist: bsdiff4
Requires-Dist: requests
Provides-Extra: gui
Requires-Dist: customtkinter>=5.2.0; extra == "gui"
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"

# pyupdator

**Delta updater for games (Torrent and HTTP Zip support).**

`pyupdator` is an independent, pip-installable Python library that lets a game
launcher (or any host application) update installed game files without
downloading the entire new release. It supports:

- **BitTorrent piece-level delta** (via `libtorrent`, optional) — download only
  the missing SHA-1 pieces of a `.torrent`.
- **HTTP ZIP delta** — read a remote ZIP's Central Directory over HTTP Range
  requests and download only the changed files.
- **Content-Defined Chunking (CDC)** via Gear/FastCDC hashing — download only
  the changed byte ranges of a single HTTP-hosted file.

The library core (`pyupdator/`) contains **no** `tkinter`, `customtkinter`, or
GUI code. A separate optional package (`pyupdator_gui/`) provides a
Tkinter/customtkinter launcher window and is installed with
`pip install pyupdator[gui]`.

## Installation

```bash
# Library core only (no GUI)
pip install pyupdator

# Library + optional GUI
pip install pyupdator[gui]
```

## Quick start

```python
from pyupdator import Updater

updater = Updater(install_dir="C:/Oyun", source="oyun.torrent")
plan = updater.analyze()
print("Plan:", plan)

updater.update(progress_callback=my_progress_func)

# Optional verification
result = updater.verify()
print("Verified:", result)
```

See `examples/basic_usage.py` for a complete GUI-free example.

## Project layout

```
pyupdator/            # library core (no GUI imports)
  __init__.py         # public API: Updater, UpdaterError, logging helpers
  core/
    __init__.py
    torrent.py        # .torrent parse, recheck, delta plan, apply, verify
    zip_engine.py     # HTTP ZIP delta + CDC chunker
    backend_manager.py# download backend detection & selection
  utils/
    __init__.py
    helpers.py        # UpdaterError, hashing, safe_join, config, ...
pyupdator_gui/        # optional Tkinter/customtkinter GUI
  __init__.py
  main_window.py      # MainWindow ported from gui.py
examples/
  basic_usage.py      # GUI-free usage example
tests/                # existing test suite moved here
pyproject.toml
README.md
```

## Updater API contract

```python
from pyupdator import Updater

updater = Updater(install_dir="C:/Oyun", source="oyun.torrent")
plan = updater.analyze()          # returns a plan dict
updater.update(progress_callback=my_func)   # applies the update
updater.verify()                  # verifies installed files against source
```

## Logging

`pyupdator` uses the standard `logging` module (logger name `"pyupdator"`).
The host launcher can forward logs to its own console or GUI:

```python
import logging
from pyupdator import add_log_handler, set_log_level

handler = logging.StreamHandler()
add_log_handler(handler)
set_log_level(logging.DEBUG)
```

## Backends

| Backend      | Capability     | Notes                              |
|--------------|----------------|------------------------------------|
| libtorrent   | PIECE_LEVEL    | Optional; true piece-level delta   |
| aria2        | FILE_LEVEL     | aria2c JSON-RPC                    |
| qBittorrent  | FILE_LEVEL     | Web API v2                         |
| uTorrent     | FILE_LEVEL     | Web UI, best effort                |
| Transmission | FILE_LEVEL     | RPC                                |
| manual       | FILE_LEVEL     | Manual/local source                |
| http_zip     | CHUNK_LEVEL    | HTTP ZIP delta / CDC               |

`libtorrent` is often unavailable on Windows + Python 3.13; the library falls
back to FILE_LEVEL backends and reports this clearly.

## Tests

Run the test suite:

```bash
python -m pytest tests/
```

Individual test scripts can also be run directly:

```bash
python tests/test_cdc_delta.py
python tests/test_zip_delta.py
```

## PyPI publishing

```bash
pip install build twine
python -m build
twine upload dist/*
```

If a PyPI token is required, set `TWINE_USERNAME` and `TWINE_PASSWORD` (or use
`~/.pypirc`). If `twine upload` returns `400 Bad Request` because the name
`pyupdator` collides with an existing package (e.g. `pyupdater`), rename the
project in `pyproject.toml` and republish.
