Skip to main content

Python bindings for GLDF (General Lighting Data Format) parsing library

Project description

CI PyPI

gldf-rs-python

Python bindings for the gldf-rs GLDF parsing library.

Overview

gldf-rs-python provides Python access to GLDF (General Lighting Data Format) file parsing and manipulation. It wraps the high-performance Rust gldf-rs library using PyO3/maturin.

GLDF files are ZIP containers containing product.xml definitions along with embedded images, photometry files (Eulumdat/IES), and L3D 3D models.

Learn more at: https://gldf.io

Installation

pip install gldf-rs-python

GLDF Viewer

Quick Start

import gldf_rs_python

# Load GLDF and convert to XML
xml = gldf_rs_python.gldf_to_xml('path/to/file.gldf')

# Load GLDF and convert to JSON
json = gldf_rs_python.gldf_to_json('path/to/file.gldf')

# Round-trip: JSON back to XML
xml2 = gldf_rs_python.xml_from_json(json)

assert xml == xml2  # True

Converting LDT/IES to GLDF

import gldf_rs_python

# Convert LDT to GLDF JSON
with open("luminaire.ldt", "rb") as f:
    gldf_json = gldf_rs_python.ldt_to_gldf_json(f.read(), "luminaire.ldt")

# Convert LDT to GLDF file
with open("luminaire.ldt", "rb") as f:
    gldf_bytes = gldf_rs_python.ldt_to_gldf_bytes(f.read(), "luminaire.ldt")
    with open("luminaire.gldf", "wb") as out:
        out.write(gldf_bytes)

# Works with IES files too
with open("luminaire.ies", "rb") as f:
    gldf_json = gldf_rs_python.ldt_to_gldf_json(f.read(), "luminaire.ies")

Working with GLDF Bytes

import gldf_rs_python

# Load GLDF from bytes (useful for web apps, streaming)
with open("product.gldf", "rb") as f:
    json_data = gldf_rs_python.gldf_from_bytes(f.read())

# Export GLDF JSON back to bytes
gldf_bytes = gldf_rs_python.gldf_json_to_bytes(json_data)

API Reference

Function Description
gldf_to_xml(path) Load GLDF file and convert to XML string
gldf_to_json(path) Load GLDF file and convert to JSON string
json_from_xml_str(xml_str) Parse XML string to JSON
xml_from_json(json_str) Parse JSON string to XML
gldf_from_bytes(data) Load GLDF from bytes and return JSON
ldt_to_gldf_json(data, filename) Convert LDT/IES to GLDF JSON
ldt_to_gldf_bytes(data, filename) Convert LDT/IES to GLDF bytes (ZIP)
gldf_json_to_bytes(json_str) Export GLDF JSON to bytes (ZIP)

Development

# Create virtual environment
python -m venv .venv
source .venv/bin/activate

# Install maturin
pip install maturin

# Build and install in development mode
maturin develop

# Build release wheel
maturin build --release

Live Demo

Try the WASM-based GLDF viewer at: https://gldf.icu

Related Crates

Crate Description
gldf-rs Core Rust library
gldf-rs-wasm WebAssembly viewer application
l3d-rs L3D 3D model format parsing
eulumdat Eulumdat/LDT photometry parsing

Release Notes

0.3.3

  • New: ldt_to_gldf_json() - Convert LDT/IES photometry to GLDF JSON
  • New: ldt_to_gldf_bytes() - Convert LDT/IES photometry to GLDF bytes (ZIP)
  • New: gldf_from_bytes() - Load GLDF from bytes and return JSON
  • New: gldf_json_to_bytes() - Export GLDF JSON to bytes (ZIP)
  • Improved error handling with proper PyValueError exceptions
  • Added eulumdat feature for LDT/IES conversion support

0.3.1

  • Updated to gldf-rs 0.3.1 with quick-xml parser
  • Part of gldf-rs monorepo restructure

0.2.0

  • Support for URL file types
  • Support for BOM-encoded UTF8 product.xml

License

MIT License

Project details


Download files

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

Source Distribution

gldf_rs_python-0.3.4.tar.gz (166.4 kB view details)

Uploaded Source

Built Distributions

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

gldf_rs_python-0.3.4-cp38-abi3-win_amd64.whl (1.8 MB view details)

Uploaded CPython 3.8+Windows x86-64

gldf_rs_python-0.3.4-cp38-abi3-musllinux_1_2_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.8+musllinux: musl 1.2+ x86-64

gldf_rs_python-0.3.4-cp38-abi3-musllinux_1_2_aarch64.whl (2.3 MB view details)

Uploaded CPython 3.8+musllinux: musl 1.2+ ARM64

gldf_rs_python-0.3.4-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64

gldf_rs_python-0.3.4-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.1 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64

gldf_rs_python-0.3.4-cp38-abi3-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

gldf_rs_python-0.3.4-cp38-abi3-macosx_10_12_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.8+macOS 10.12+ x86-64

File details

Details for the file gldf_rs_python-0.3.4.tar.gz.

File metadata

  • Download URL: gldf_rs_python-0.3.4.tar.gz
  • Upload date:
  • Size: 166.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for gldf_rs_python-0.3.4.tar.gz
Algorithm Hash digest
SHA256 bae363d4cac3d4f7cd7e29696a9c247fabb7e1e319850f1968a827cb94738b8e
MD5 5acf57aba3848c8b78c1ce0740e58cbb
BLAKE2b-256 d3c4222d9d6f3230d071affc8189987e9be9079f802699ed9d360f105697c212

See more details on using hashes here.

Provenance

The following attestation bundles were made for gldf_rs_python-0.3.4.tar.gz:

Publisher: python-publish.yml on holg/gldf-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gldf_rs_python-0.3.4-cp38-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for gldf_rs_python-0.3.4-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 61401882f6be0747dcf0931f224a91a9950288b9e6c1b35f4b0bc845df47d5d6
MD5 db502020fc0fc2f0bacd8c255613694f
BLAKE2b-256 f1fbbbaa559e4ac2df4b2f52bc55ee04ae0ae3db9628457bfab5a5f1f0889c43

See more details on using hashes here.

Provenance

The following attestation bundles were made for gldf_rs_python-0.3.4-cp38-abi3-win_amd64.whl:

Publisher: python-publish.yml on holg/gldf-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gldf_rs_python-0.3.4-cp38-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for gldf_rs_python-0.3.4-cp38-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 c2f212acd87cefac3d33010d23067bacb6d4dfc0caf6e268ae2baf46f670e369
MD5 e04102eb6dd4a50d8b4b61a47b448a5b
BLAKE2b-256 73a975bab7b079e8d6fe264fdd16092584e565d40b232a6124fac62fef8b942b

See more details on using hashes here.

Provenance

The following attestation bundles were made for gldf_rs_python-0.3.4-cp38-abi3-musllinux_1_2_x86_64.whl:

Publisher: python-publish.yml on holg/gldf-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gldf_rs_python-0.3.4-cp38-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for gldf_rs_python-0.3.4-cp38-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 5f2878345f18eb4c1419fd2b69af45c0956ff9ccc9fff509732f98a9f1ffb881
MD5 10a2e48fde7fa2d8072208b9ce9a2b70
BLAKE2b-256 97d23b76eee097ff43a94c77cf0b38306c0a4942f7168d3658bd906d22737ccd

See more details on using hashes here.

Provenance

The following attestation bundles were made for gldf_rs_python-0.3.4-cp38-abi3-musllinux_1_2_aarch64.whl:

Publisher: python-publish.yml on holg/gldf-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gldf_rs_python-0.3.4-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for gldf_rs_python-0.3.4-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 25e84592a0af697c925cc0c0a5719c31aebe7b2b997da9d279510a6e6b90858f
MD5 11ea04c0cbed26f108ffe3c86e3bb156
BLAKE2b-256 fff49b667af9b3b8b5634db5a10d2de0bbc19e10020bb68ac5b7778eeb3fed46

See more details on using hashes here.

Provenance

The following attestation bundles were made for gldf_rs_python-0.3.4-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: python-publish.yml on holg/gldf-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gldf_rs_python-0.3.4-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for gldf_rs_python-0.3.4-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 eefb96eceda0902e04515ccc33877af84ca82232d140be3765e3bbe51d23264e
MD5 db117a2ddd608bf8a48fb76d86038001
BLAKE2b-256 4864c50793d97390a0bf2ae37352fb315831084d4943d43d438a74c2f94914e2

See more details on using hashes here.

Provenance

The following attestation bundles were made for gldf_rs_python-0.3.4-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: python-publish.yml on holg/gldf-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gldf_rs_python-0.3.4-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for gldf_rs_python-0.3.4-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cca68ab1162f4f4536080920849fa7f3a6825312e4cc7486b3c2a01f1fa6f5df
MD5 31c39ea785a0b1b7b710c9a6787e1fbc
BLAKE2b-256 0940ae84e8551bfb4d4b309d89a2a3c497a9931a32c79dda12f70ae4d59547bc

See more details on using hashes here.

Provenance

The following attestation bundles were made for gldf_rs_python-0.3.4-cp38-abi3-macosx_11_0_arm64.whl:

Publisher: python-publish.yml on holg/gldf-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gldf_rs_python-0.3.4-cp38-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for gldf_rs_python-0.3.4-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 59c6ed36c90bd0c0e472e25cff29026e3d463d2626655164b71a24230bf3cee6
MD5 390469d2dcc9f485c9e3fdeff42ae73e
BLAKE2b-256 69ef82e68cbbfcebef144d21bac1053c2bb1abeab9d5725348313bea6c4bb69e

See more details on using hashes here.

Provenance

The following attestation bundles were made for gldf_rs_python-0.3.4-cp38-abi3-macosx_10_12_x86_64.whl:

Publisher: python-publish.yml on holg/gldf-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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