feat(py): PyO3 bindings (fleischwolf-py) — docling-shaped drop-in, local-only - #30
Merged
Merged
Conversation
crates/fleischwolf-py: a strangler-fig replacement for Python docling's common path — DocumentConverter(strict, fetch_images, artifacts_path) .convert(path) / .convert_bytes(name, data) returning a ConversionResult with .status and .document (export_to_markdown / export_to_dict / export_to_json / save_as_*). Conversion releases the GIL; paths accept str/os.PathLike; bytes input detects the format from the name. Models are handled on the Python side the way docling handles its artifacts: fleischwolf.download_models() fetches the pipeline assets (incl. pdfium and the INT8 variants) from the models-v1 GitHub release into ~/.cache/fleischwolf ( overrides) with pure urllib, and ensure_env() — called by the converter constructor — points the native pipeline at them via the standard DOCLING_*/PDFIUM_* env vars, preferring INT8 like the Rust default (FLEISCHWOLF_FP32 opts out) and never overriding explicitly-set variables. Deliberately unpublished and outside the Cargo workspace/crates.io publish flow (empty [workspace], publish = false; the PyPI name is tentative). Built locally with maturin — see the crate README for the try-it steps. Verified in-container: maturin develop --release; download_models() pulled 623 MB from the release; Markdown/dict/bytes/pathlib round-trips pass; a PDF converted through the full ML pipeline from a foreign CWD with a clean environment is byte-identical to the CLI's output. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017fKFbatf55BK5j8vr3dZjj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The strangler-fig PyO3 bindings from the roadmap — experimental, not published anywhere (the PyPI name is tentative), built locally with maturin:
DocumentConverter(strict, fetch_images, artifacts_path),.convert(path)(str/os.PathLike, GIL released for the conversion),.convert_bytes(name, data)(theDocumentStreamcounterpart),ConversionResult.status/.document,DoclingDocument.export_to_markdown/export_to_dict/export_to_json/save_as_*.fleischwolf.download_models()fetches the pipeline assets (incl. pdfium and the INT8 variants) from themodels-v1GitHub release into~/.cache/fleischwolf($FLEISCHWOLF_CACHE_DIRoverrides) with stdliburllib;ensure_env()— called by the constructor — points the native pipeline at the cache via the standardDOCLING_*/PDFIUM_*env vars, preferring INT8 like the Rust default and never overriding explicitly-set variables. Declarative formats need no models at all.[workspace],publish = false) — outside the repo workspace, untouched by CI'scargo test/clippy and byci_publish.sh. Renaming the distribution later costs nothing.maturin develop --release→download_models()→ convert); MIGRATION §6 moves PyO3 from "planned" to "experimental in-repo".Testing (all in-container, per the README steps)
maturin develop --releasebuilds and installs into a fresh venv.download_models()pulled 623 MB from the release (required + optional INT8/.dataassets, 404-tolerant optional path exercised earlier against a tag without int8).export_to_dict()(schema 1.10.0), bytes API andpathlib.Pathinputs pass without any models configured.🤖 Generated with Claude Code
https://claude.ai/code/session_017fKFbatf55BK5j8vr3dZjj
Generated by Claude Code