Metadata-Version: 2.4
Name: macmon-lib
Version: 0.10.0
Summary: Fast Python bindings for macmon with a bundled native library and no external runtime binaries
Project-URL: Repository, https://github.com/homm/macmon-bindings
Project-URL: Source, https://github.com/homm/macmon-bindings/tree/main/python
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: cffi<2,>=1.17

Fast Python bindings for `macmon`.

The wheel bundles the native library, so it installs and runs without separate external binaries.

# Usage

`Sampler.metrics()` returns the current cumulative sample immediately.
The caller is responsible for timing and timeout policy, so the library does not need its own async API.

```python
import asyncio

from macmon import Sampler, soc_info


async def main() -> None:
    info = soc_info()
    print(info.chip_name)

    with Sampler() as sampler:
        while True:
            metrics = sampler.metrics()
            print(
                "chip_w=%.2f media_w=%.2f cpu_usage=%.3f gpu_usage=%.3f"
                % (
                    metrics.chip_power,
                    metrics.media_power,
                    metrics.cpu_scaled_ratio,
                    metrics.gpu_scaled_ratio,
                )
            )
            await asyncio.sleep(1.0)


asyncio.run(main())
```

For a more complete example, see [example.py](example.py).

# Develop

## Editable install

From the repository root:

```sh
make cmacmon
cd python
pip install -e .
```

## Wheel

From the repository root:

```sh
make python_wheel
```

The repaired wheel is written to `python/wheelhouse/`.
