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 byLEPTRIS_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'slib/leptris.rb)leptris/document.py,element.py,node.py,xpath.py,error.py— typed wrapperstests/— pytest suite (run:pytestwithLEPTRIS_LIB_PATHset)
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2826e5e3843b681743a9fd6ef4d211d1701b18972901337fe9465eccda3b5c58
|
|
| MD5 |
60ff709a6b4b38c6715502c44cccc5f6
|
|
| BLAKE2b-256 |
ede4a6126408127aa352a5e178027964dcb0f572c84f098332bf06835de73db4
|
Provenance
The following attestation bundles were made for leptris-1.2.0.tar.gz:
Publisher:
release.yml on leptris/leptris-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
leptris-1.2.0.tar.gz -
Subject digest:
2826e5e3843b681743a9fd6ef4d211d1701b18972901337fe9465eccda3b5c58 - Sigstore transparency entry: 2570812188
- Sigstore integration time:
-
Permalink:
leptris/leptris-py@4649cde2845601bbbab5452f30a8440d40ac26ec -
Branch / Tag:
refs/heads/main - Owner: https://github.com/leptris
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4649cde2845601bbbab5452f30a8440d40ac26ec -
Trigger Event:
workflow_dispatch
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a51786372c59948e42475303728d45f3acb323edb36f5d81f99fde7ac6ea6d05
|
|
| MD5 |
107d6ee5a6f9338990c35af1cce89acc
|
|
| BLAKE2b-256 |
b78944ade339a0d95423f1fec9ed5e951807a59b43b003aa192a1ed3c606296f
|
Provenance
The following attestation bundles were made for leptris-1.2.0-py3-none-any.whl:
Publisher:
release.yml on leptris/leptris-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
leptris-1.2.0-py3-none-any.whl -
Subject digest:
a51786372c59948e42475303728d45f3acb323edb36f5d81f99fde7ac6ea6d05 - Sigstore transparency entry: 2570812233
- Sigstore integration time:
-
Permalink:
leptris/leptris-py@4649cde2845601bbbab5452f30a8440d40ac26ec -
Branch / Tag:
refs/heads/main - Owner: https://github.com/leptris
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4649cde2845601bbbab5452f30a8440d40ac26ec -
Trigger Event:
workflow_dispatch
-
Statement type: