Metadata-Version: 2.4
Name: layrz-sdk
Version: 4.35.1
Summary: Layrz SDK for Python
Author: Layrz, Inc.
Maintainer: Luis Reyes, Kasen Li, Miguel Zauzich, Angel Prieto
Maintainer-email: Kenny Mochizuki <kenny@layrz.com>
License-Expression: MIT
Project-URL: Repository, https://github.com/layrz-software/layrz-sdk
Project-URL: Changelog, https://github.com/layrz-software/layrz-sdk/blob/main/CHANGELOG.md
Keywords: sdk,lcl,layrz compute language,layrz
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Operating System :: OS Independent
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Requires-Python: >=3.13
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: xlsxwriter<4.0.0,>=3.2.5
Requires-Dist: pydantic>=2.12.3
Requires-Dist: geopy>=2.4.1
Requires-Dist: shapely>=2.1.1
Requires-Dist: strenum>=0.4.15
Requires-Dist: requests>=2.32.4
Requires-Dist: tzdata>=2025.2
Requires-Dist: ty>=0.0.1a34
Requires-Dist: pathvalidate>=3.3.1
Requires-Dist: msoffcrypto-tool<7.0.0,>=6.1.0
Dynamic: license-file

# Layrz SDK for Python

[![PyPI version](https://img.shields.io/pypi/v/layrz-sdk?logo=pypi&logoColor=white)](https://pypi.org/project/layrz-sdk/)
[![Python](https://img.shields.io/pypi/pyversions/layrz-sdk?logo=python&logoColor=white)](https://pypi.org/project/layrz-sdk/)
[![GitHub license](https://img.shields.io/github/license/layrz-software/layrz-sdk?logo=github)](https://github.com/layrz-software/layrz-sdk)

It's a group of classes/SDK that can help you to implement scripts into Layrz modules, or incorporate them into your own projects.

## Installation

To use this package, add `layrz-sdk` to your project:

```bash
pip install layrz-sdk
```

or, if you use [uv](https://docs.astral.sh/uv/):

```bash
uv add layrz-sdk
```

Requires Python `>=3.13`.

## Requirements

### Installing from PyPI

Nothing extra is needed on the platforms with a prebuilt wheel. The published wheels are platform-specific (`py3-none-<platform>`) and bundle the compiled LCL engine (`layrz_sdk/_lib/liblayrz_lcl.so` on Linux, `layrz_sdk/_lib/liblayrz_lcl.dylib` on macOS).

Prebuilt wheels:

- Linux x86_64 and aarch64 (`manylinux_2_28`, glibc).
- macOS arm64 and x86_64 (macOS 12+).

The LCL engine (`LclCore`) is **not supported on musl-based systems such as Alpine Linux**: the Go shared library cannot be loaded there. On musl, the sdist installs without Go or a C compiler (the library build is skipped), `import layrz_sdk` works and everything except `LclCore.perform` is available; `LclCore.perform` raises `ImportError`. Use a glibc-based image such as `python:3.13-slim` if you need LCL. The `LAYRZ_SDK_LCL_LIB` override does not lift this limitation.

On other platforms without a prebuilt wheel (for example Windows or older glibc), pip installs the source distribution (sdist) and compiles the library during installation. The sdist embeds the Go source it needs, so you need:

- Go matching the version declared in `go/go.mod` (currently `1.27.0`).
- A C compiler (`gcc` or `clang`) and `CGO_ENABLED=1`.

### Building from source

Installing from a git checkout, running `uv build`, `uv sync` or the test suite compiles the LCL engine, so you need:

- The monorepo layout (`python/` next to `go/`).
- Go matching the version declared in `go/go.mod` (currently `1.27.0`).
- CGO enabled (`CGO_ENABLED=1`) and a C compiler (`gcc` or `clang`; on macOS, the Xcode Command Line Tools).
- On macOS, `MACOSX_DEPLOYMENT_TARGET` set to `12.0` or higher.

The library is built with `make -C go cabi OUT=<path>`, which runs `go build -buildmode=c-shared` on `go/cabi`. The Python build runs it automatically and writes the result to `python/layrz_sdk/_lib/`.

### Layrz Compute Language (LCL)

`layrz_sdk.lcl.LclCore` is backed by a Go engine that is loaded with the standard library `ctypes`. The library is loaded lazily on first LCL use, so a missing library only breaks LCL and never `import layrz_sdk`.

`LclCore.perform()` keeps returning a JSON-encoded string. The `additional_globals` and `additional_locals` arguments are deprecated as of `4.35.0`: `LclCore.perform()` still accepts them but ignores them (the Go engine cannot use Python callables or values from them) and emits a `DeprecationWarning` when they are passed. They will be removed in a future major version. Formulas support LCL function calls, literals, arithmetic, comparisons and `and` / `or` / `not`, but no arbitrary Python.

## FAQ

### Why is this package called `layrz-sdk`?

All packages developed by [Layrz](https://layrz.com) are prefixed with `layrz`, check out our other packages on [PyPI](https://pypi.org/user/goldenm/) and [pub.dev](https://pub.dev/publishers/goldenm.com/packages).

### What is this package for?

This is the Python side of the multi-language Layrz SDK monorepo, which also ships a Go SDK (`github.com/layrz-software/layrz-sdk/go/v4`) and a Dart/Flutter SDK (`layrz_sdk` on pub.dev).

<b>What's inside:</b> the shared entities (100+ Pydantic models for assets, devices, sensors, geofences, telemetry messages, charts, broadcasts, modbus, operations, reports and push notifications), the Layrz Compute Language (LCL) interpreter for telemetry scripting, and helpers (UUIDv7 composition/extraction, color conversion) — converting Layrz API and platform payloads into typed Python objects. More information about our SDKs can be found in our [documentation](https://developers.layrz.com/Kits/Sdk).

### I have a question, how can I contact you?

If you need more assistance, you can open an issue on the [Repository](https://github.com/layrz-software/layrz-sdk) and we're happy to help you :)

## License

This project is licensed under the MIT License - see the [LICENSE](https://github.com/layrz-software/layrz-sdk/blob/main/LICENSE) file for details.

Copyright © 2026 Layrz, Inc.

## Who are we? / Want to work with us?

**Layrz, Inc.** is leading the next industrial revolution. We build Layrz, a modular, plug & play IoT platform that helps companies and industries monitor, automate and control their operations in real time, from sensors and alerts to decisions, across Latin America, the United States and Europe.

Want to build with us? Contact us at [sales@layrz.com](mailto:sales@layrz.com) or via WhatsApp at [+(507)-6979-3073](https://wa.me/50769793073?text=From%20layrz-sdk%20python%20library.%20Hello).
