Repository navigation
Split python-libzim between reader and writer parts - #292
Conversation
7e3bf7b to
3cce80a
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #292 +/- ##
==========================================
+ Coverage 93.70% 95.29% +1.59%
==========================================
Files 1 1
Lines 635 638 +3
==========================================
+ Hits 595 608 +13
+ Misses 40 30 -10 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
3a13b29 to
3803f8c
Compare
3803f8c to
1f37944
Compare
|
@benoit74 once look into this please thanks! |
benoit74
left a comment
There was a problem hiding this comment.
Automated review of this PR's reader/writer split. Findings below, each with a suggested fix where one is mechanical; the setup.py detection and CI-coverage ones are judgment calls for you to evaluate rather than blind applies.
1f37944 to
3dcff3b
Compare
benoit74
left a comment
There was a problem hiding this comment.
Reading all modifications in setup.py twice, I realize that automated detection seems too fragile IMHO ; I would rather prefer we resort only on an env variable LIBZIM_WITHOUT_WRITER which makes the choice explicit in all cases. Pretty concerned that we will have to force detection in some cases, and not build with writer in cases where we would have expected to.
This also makes codes much simpler, which is always good from a maintenance perspective
WDYT?
3dcff3b to
0a5a53d
Compare
|
@benoit74 agreed, and done — detection is gone entirely.
The failure mode is now the one you want: if a reader-only build forgets the variable, the build tries to compile the writer bindings against a writer-less libzim and fails loudly at compile time, rather than silently producing a wheel without writer support. Nothing can silently downgrade a writer build either. Verified after the change: default build 180 passed; |
9799b05 to
0a5a53d
Compare
Cython cannot conditionally parse `cdef extern` blocks, so declare the writer API through a local shim header that only includes libzim's writer headers when the library was built with writer support. Guard the writer implementations (C++ wrappers, writer callbacks, Hint, Creator and the libzim.writer registration) with LIBZIM_WITHOUT_WRITER, and let the build select that path explicitly through the LIBZIM_WITHOUT_WRITER env var. On a writer-less libzim the extension now builds and `import libzim.writer` raises ImportError, which is what Android/reader-only wheels need (openzim#283). The reader-only build is covered by a dedicated CI job. Adds tests for lazy submodule loading and creator guards. Fixes openzim#287
0a5a53d to
574dbf0
Compare
|
Just skimmed through it. Looks good 👍 What bothers me is that we'll be publishing the very same Now that the work for a reader-only libzim has been done, I think we should discuss (outside this PR) how we want to distribute this. I'd be happy to pull a read-only libzim in many scenarios. The On a personal note, I'd find |
|
Thank you @rgaudin
This is unfortunately the decision which has already been taken at libzim level, python-libzim can only cope with that decision and report concern upstream. I will do so.
Same problem ; we do not have split between read-only + write-only libzim binaries on most platforms, so we can't build a read-only python-libzim with a "writer" extra ; this requires to have libzim-core + libzim-writer binaries. Otherwise we just remove the writer part of python-libzim while still pulling the whole libzim binaries ... which does not really makes sense (no strong added value IMHO).
Indeed ; since there is no platform building without writer in this PR, it does not seems reasonable to do in this PR ; but we clearly need to document in #283 that Android platform is available but without writer module.
|
|
Opened openzim/libzim#1139 to discuss the "extra" approach. |
Split writer/reader parts to support libzim built without writer (e.g. Android/reader-only builds).
Fixes #287