Skip to main content

Fast Python bindings for macmon with a bundled native library and no external runtime binaries

Project description

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.

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(
                "board_w=%.2f cpu_usage=%.3f gpu_usage=%.3f"
                % (
                    metrics.power.board,
                    metrics.cpu_usage[0].usage if metrics.cpu_usage else 0.0,
                    metrics.gpu_usage[0].usage if metrics.gpu_usage else 0.0,
                )
            )
            await asyncio.sleep(1.0)


asyncio.run(main())

For a more complete example, see example.py.

Develop

Editable install

From the repository root:

make cmacmon
cd python
pip install -e .

Wheel

From the repository root:

make python_wheel

The repaired wheel is written to python/wheelhouse/.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

macmon_lib-0.7.0.post0-cp39-abi3-macosx_11_0_arm64.whl (265.5 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

File details

Details for the file macmon_lib-0.7.0.post0-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for macmon_lib-0.7.0.post0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 de5b448fa3d8d35bd8473f54df09b5899b0b5597802e9cbc9203a78955b007e7
MD5 e21015e6521b59bdd7f4e727946f014d
BLAKE2b-256 f08ff9124a38860cb65abf8acc25ee35ec657987a332b1cc6a975234dc981f1c

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