Skip to main content

leptris (Python) — bindings for libleptris

leptris wraps the libleptris C API (XML 1.0 parsing, XPath 1.0) using cffi in ABI mode — the cdef in leptris/_ffi.py mirrors libleptris's public headers.

The pinned libleptris version lives in libleptris-version.txt (lockstep releases); CI builds it from the release tarball. The binding loads the shared library from LEPTRIS_LIB_PATH or the loader path.

Requirements

  • Python 3.8+
  • cffi (pip install cffi)
  • libleptris as a shared library (libleptris.dylib / libleptris.so) on the loader path, or pointed to by LEPTRIS_LIB_PATH. For a development checkout:
cmake -B build -S . -DLEPTRIS_BUILD_SHARED=ON
cmake --build build --target leptris_shared
export LEPTRIS_LIB_PATH=$PWD/build/src/libleptris.dylib

Quick start

from leptris import Document

doc = Document.parse("<library><book id='1'>Ulysses</book></library>")

doc.root.name                     # "library"
book = doc.root.first_child_element
book.name                         # "book"
book.attribute("id")              # "1"
book.text                         # "Ulysses"

doc.xpath("count(//book)")        # 1.0
[e.text for e in doc.xpath("//book")]   # ["Ulysses"]

doc.close()   # or: with Document.parse(xml) as doc: ...

Layout

  • leptris/_ffi.py — cdef + shared-library loading (single source of the C surface, mirroring the Ruby binding's lib/leptris.rb)
  • leptris/document.py, element.py, node.py, xpath.py, error.py — typed wrappers
  • tests/ — pytest suite (run: pytest with LEPTRIS_LIB_PATH set)

Memory model

The Document owns the whole tree and its pool. Accessor strings are copied into Python str at the boundary, so nothing depends on document lifetime after a call returns. Elements keep a reference to their Document, so the pool cannot be freed while any wrapper is alive. Prefer explicit close() / the context manager; __del__ is a refcounting safety net, not a contract.

Versioning

The package version tracks libleptris (lockstep): library 1.1.0 ↔ leptris 1.1.0.

Publishing

Releases publish to PyPI via .github/workflows/release.yml, using PyPI trusted publishing (no stored credentials). The workflow runs on manual dispatch (ships the version in pyproject.toml) and is called by the libleptris release flow (publish: true), so every libleptris release ships the wheel.

Local development

python3 -m venv .venv
./.venv/bin/pip install --upgrade build setuptools wheel pytest cffi
./.venv/bin/python -m build
LEPTRIS_LIB_PATH=../../build-shared/src/libleptris.dylib \
  ./.venv/bin/python -m pytest tests/ -q

Download files

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

Source Distribution

leptris-1.2.0.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

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

leptris-1.2.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file leptris-1.2.0.tar.gz.

File metadata

  • Download URL: leptris-1.2.0.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for leptris-1.2.0.tar.gz
Algorithm Hash digest
SHA256 2826e5e3843b681743a9fd6ef4d211d1701b18972901337fe9465eccda3b5c58
MD5 60ff709a6b4b38c6715502c44cccc5f6
BLAKE2b-256 ede4a6126408127aa352a5e178027964dcb0f572c84f098332bf06835de73db4

See more details on using hashes here.

Provenance

The following attestation bundles were made for leptris-1.2.0.tar.gz:

Publisher: release.yml on leptris/leptris-py

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

File details

Details for the file leptris-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: leptris-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for leptris-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a51786372c59948e42475303728d45f3acb323edb36f5d81f99fde7ac6ea6d05
MD5 107d6ee5a6f9338990c35af1cce89acc
BLAKE2b-256 b78944ade339a0d95423f1fec9ed5e951807a59b43b003aa192a1ed3c606296f

See more details on using hashes here.

Provenance

The following attestation bundles were made for leptris-1.2.0-py3-none-any.whl:

Publisher: release.yml on leptris/leptris-py

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

Release history Release notifications | RSS feed

1.27.1

6 files

1.27.0

6 files

1.26.1

6 files

1.26.0

6 files

1.25.4

6 files

1.25.3

6 files

1.25.2

6 files

1.25.1

6 files

1.25.0

6 files

1.24.3

6 files

1.24.2

6 files

1.24.1

6 files

1.24.0

6 files

1.23.3

6 files

1.23.2

6 files

1.23.1

6 files

1.23.0

6 files

1.22.2

6 files

1.22.1

6 files

1.22.0

6 files

1.21.0

6 files

1.20.0

6 files

1.19.0

6 files

1.18.0

6 files

1.17.1

6 files

1.17.0

6 files

1.16.1

6 files

1.16.0

6 files

1.15.1

6 files

1.15.0

6 files

1.14.3

6 files

1.14.2

6 files

1.14.1

6 files

1.14.0

6 files

1.13.3

6 files

1.13.2

6 files

1.13.1

6 files

1.13.0

6 files

1.12.0

6 files

1.11.1

6 files

1.11.0

6 files

1.10.0

6 files

1.9.93.2

6 files

1.9.93.0

6 files

1.9.90.0

6 files

1.9.87.0

6 files

1.9.86.0

6 files

1.9.84.0

6 files

1.9.83.0

6 files

1.9.80.0

6 files

1.9.79.0

6 files

1.9.76.0

6 files

1.9.0

6 files

1.8.0

6 files

1.7.0

6 files

1.6.1

6 files

1.6.0

5 files

1.5.0

2 files

1.4.1

2 files

1.4.0

2 files

1.3.1

2 files

1.3.0

2 files

This release

1.2.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page