Skip to content

Split python-libzim between reader and writer parts - #289

Closed
pawank925 wants to merge 564 commits into
openzim:mainfrom
pawank925:split-writer-reader
Closed

pawank925 wants to merge 564 commits into
openzim:mainfrom
pawank925:split-writer-reader

Conversation

@pawank925

@pawank925 pawank925 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Splits writer/reader parts to support libzim built without writer support (e.g. Android). When LIBZIM_WITHOUT_WRITER is detected or writer headers/symbols unavailable, writer module is created as empty/dummy or not fully functional. Adds writer as optional extra, guards C++ bindings, updates tests to skip when writer unavailable.

Pawan Kumar added 30 commits March 18, 2023 12:24
We used to generate our wheels in a very hacky way, by:
- manually downloading libzim binaries into a dedicated location
- building the extension, manipulating the LD_LIBRARY_PATH
- manipulate the build directory to place libzim binary inside
- eventually creating the wheel

It was:
- not straightforward.
- unclear what the outcome was
- often bundling libzim in sdist
- not integratable with other tools

This now builds correct wheels and source using an in-setup-only process.
Running QA, then tests on a handful of targets and getting coverage
- Building wheels on 3.7 to 3.11
- Testing on CPython 3.7 to 3.11
- Testing all wheels via cibuildwheel
- Excluding PyPy
Replaced the release-only release workflow with a new wheels one that serves 2 purposes:
- Build all supported wheels + sdist on every push/PR to ensure publication is not affected
- Additionnaly publish those to PyPI if triggered via a release
Although cibuildwheel specifies the target arch for each of its builds,
a regular user would attempt to build with `python3 -m build`, defaulting to universal2

This adds support for this use case, by downloading the two archs libzim and
creating a universal libzim before building the universal extension.
Using /usr/bin/env prefix, codefactor is happy as it's now an absolute path
yet it's still using the user's environment, allowing overrides, which we'd prefer.

Also disables urlopen warning as we control the url protocol
Add credentials-aware signing keychain for macOS signing
requests all (macOS) builds to sign
Split wheels workflow into:
- wheels workflow ran on PRs to ensure we can build properly
- release workflow with release environment that builds and uploads to PyPI
Latest test (accented) requires post 8.2.0 libzim to work.
Pawan Kumar added 17 commits October 25, 2026 17:19
Fix openzim#232

Adds a new illustration module with the IllustrationInfo value object,
and new width/height/scale-aware illustration APIs:
- writer.Creator.add_illustration(content, width, height=None, scale=1.0)
  and add_illustration_info(content, info) for full control (e.g. extra
  attributes), mirroring libzim's own IllustrationInfo-based overload
- reader.Archive.get_illustration_item(width=None, height=None, scale=None)
  and get_illustration_item_info(info), with the same shortcut/mirror split
- reader.Archive.get_illustrations_info(width=None, height=None, min_scale=None)
  to discover available illustrations

IllustrationInfo is an immutable namedtuple-based value object:
width/height/scale/extra_attributes are read-only, extra_attributes is
defensively copied into an immutable mapping on construction, and
changing a value means building a new instance (e.g. via `._replace()`).
as_metadata_item_name/from_metadata_item_name bridge to libzim's own
C++ implementation for correctness.
Add support for new illustrations APIs in libzim 9.4.0
…title

Add test for Archive.get_entry_by_title with distinct title and title…
…id-public

Make Archive.get_entry_by_id public and deprecate _get_entry_by_id
…pers

Add tests for indexdata helper functions
…ch-and-snippets

Support multi-archive search and SearchResult with snippets
Date conversion was removed in openzim#190 but the type stub still advertised
datetime.date and datetime.datetime.
…ution

SuggestionSearch and SuggestionResultSet were declared in the type stubs
but not exported by libzim.suggestion at runtime, so importing them failed.

create_module reused its name argument as loop variable, so each submodule
was also registered in sys.modules under its last member name (e.g.
sys.modules['Searcher']).
- set_cluster_cache_max_size parameter is size_in_bytes, not nb_clusters
- IllustrationInfo accepts extra_attributes=None
- declare enum members with values so type checkers see them as members
- declare __all__ and mark Cython extension classes as disjoint bases
- fix .pyx annotations: implicit Optional, and config methods returning Self
- mypy.stubtest checks names, parameters and defaults
- check_stub_annotations compares stubs annotations with the ones Cython
  keeps on compiled functions, which stubtest does not check
Check type stubs against compiled module, fix detected drifts
@pawank925
pawank925 marked this pull request as draft October 28, 2026 01:39
@pawank925
pawank925 force-pushed the split-writer-reader branch from 985563a to 1a442d2 Compare October 28, 2026 01:55
@pawank925
pawank925 marked this pull request as ready for review October 28, 2026 02:21
@pawank925 pawank925 closed this Oct 28, 2026
@pawank925
pawank925 force-pushed the split-writer-reader branch from d2c8a52 to d23d15d Compare October 28, 2026 02:30
@pawank925

Copy link
Copy Markdown
Contributor Author

tested it here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant