Metadata-Version: 2.4
Name: distromate-dm-api
Version: 1.2.0
Summary: DistroMate License Verification SDK for Python
Author: DistroMate
License: MIT
Project-URL: Homepage, https://github.com/yangsengui/dm-api-python
Project-URL: Repository, https://github.com/yangsengui/dm-api-python
Project-URL: Documentation, https://github.com/yangsengui/dm-api-python#readme
Keywords: distromate,license,verification,sdk
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: Microsoft :: Windows
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: cryptography>=41.0.0
Provides-Extra: dev
Requires-Dist: build>=1.2.2; extra == "dev"
Requires-Dist: twine>=5.1.1; extra == "dev"
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: mypy>=1.0; extra == "dev"
Dynamic: license-file

# dm-api-python

Python SDK for DistroMate `dm_api` native library.

## Install

```bash
pip install distromate-dm-api
```

## Quick Start (License)

```python
from dm_api import DmApi

api = DmApi()

api.set_product_data("<product-data>")
api.set_product_id("your-product-id")
api.set_license_key("XXXX-XXXX-XXXX")

if not api.activate_license():
    raise RuntimeError(api.get_last_error() or "activation failed")

if not api.is_license_genuine():
    code = api.get_last_activation_error()
    name = api.get_activation_error_name(code)
    raise RuntimeError(f"license check failed: {name}, err={api.get_last_error()}")
```

## API Groups

- License setup: `set_product_data`, `set_product_id`, `set_data_directory`, `set_debug_mode`, `set_custom_device_fingerprint`
- License activation: `set_license_key`, `set_license_callback`, `activate_license`, `get_last_activation_error`
- License state: `is_license_genuine`, `is_license_valid`, `get_server_sync_grace_period_expiry_date`, `get_activation_mode`
- License details: `get_license_key`, `get_license_expiry_date`, `get_license_creation_date`, `get_license_activation_date`, `get_activation_creation_date`, `get_activation_last_synced_date`, `get_activation_id`
- Update: `check_for_updates`, `download_update`, `cancel_update_download`, `get_update_state`, `get_post_update_info`, `ack_post_update_info`, `wait_for_update_state_change`, `quit_and_install`
- General: `get_library_version`, `json_to_canonical`, `get_last_error`, `reset`

## Update API Notes

- Update APIs return parsed JSON envelope (`dict`) when transport succeeds.
- If native API returns `NULL`, Python SDK returns `None`; check `get_last_error()`.
- `quit_and_install()` returns native `int` status code directly:
  - `1`: accepted, process should exit soon
  - `-1`: business-level rejection (check `get_last_error()`)
  - `-2`: transport/parse error

## Environment Variables

- `DM_API_PATH`: optional path to native library
- `DM_APP_ID`, `DM_PUBLIC_KEY`: optional defaults for app identity
- `DM_LAUNCHER_ENDPOINT`, `DM_LAUNCHER_TOKEN`: launcher IPC variables used by update APIs

## Release

- CI workflow validates package build.
- Tag `v*` triggers publish workflow to PyPI.
- Required secret: `PYPI_API_TOKEN`.
