Skip to content

Commit 8ce84b5

Browse files
committed
Use libzim 7.2.2
- Use libzim 7.2.2 for release and ci workflows - Updated tests to new libzim 7.2+ behavior (exceptions on duplicates) - Use latest Cython version
1 parent 53e4297 commit 8ce84b5

File tree

8 files changed

+42
-16
lines changed

8 files changed

+42
-16
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- v*
77

88
env:
9-
LIBZIM_VERSION: 7.1.0
9+
LIBZIM_VERSION: 7.2.2
1010
LIBZIM_INCLUDE_PATH: include/zim
1111
TWINE_USERNAME: __token__
1212
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
@@ -100,7 +100,7 @@ jobs:
100100
101101
- name: Build cython and sdist
102102
run: |
103-
pip install --upgrade "cython>=0.29.26,<3.0" setuptools pip wheel
103+
pip install --upgrade "cython>=0.29.28,<3.0" setuptools pip wheel
104104
python3 setup.py build_ext --rpath $RPATH
105105
if [[ "${{ matrix.python-version }}" == "3.6" ]]
106106
then

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: test
22
on: [push]
33

44
env:
5-
LIBZIM_VERSION: 7.1.0
5+
LIBZIM_VERSION: 7.2.2
66
LIBZIM_INCLUDE_PATH: include/zim
77
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
88
PROFILE: 1
@@ -56,7 +56,7 @@ jobs:
5656
run: |
5757
echo LIBZIM_EXT=so >> $GITHUB_ENV
5858
echo LIBZIM_RELEASE=libzim_linux-x86_64-$LIBZIM_VERSION >> $GITHUB_ENV
59-
echo LIBZIM_LIBRARY_PATH=lib/x86_64-linux-gnu/libzim.so.7.1.0 >> $GITHUB_ENV
59+
echo LIBZIM_LIBRARY_PATH=lib/x86_64-linux-gnu/libzim.so.7.2.2 >> $GITHUB_ENV
6060
6161
- name: Cache libzim dylib & headers
6262
uses: actions/cache@master
@@ -91,7 +91,7 @@ jobs:
9191
9292
- name: Build cython, sdist, and bdist_wheel
9393
run: |
94-
pip install --upgrade pip install "cython>=0.29.26,<3.0" setuptools pip wheel
94+
pip install --upgrade pip install "cython>=0.29.28,<3.0" setuptools pip wheel
9595
python3 setup.py build_ext --inplace
9696
python3 setup.py sdist bdist_wheel
9797

CHANGELOG.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12-
* getMetadataItem support (#127)
13-
* Added Python3.10 Support
12+
* `Archive.get_metadata_item()` (#127)
13+
* Python 3.10 Support
1414

1515
### Changed
1616

17+
* using libzim 7.2.2
18+
* RuntimeError exception is now raises on invalid/duplicate entries
1719
* Allow setting mimetype for metadata
1820
* Updated Cython to 0.29.28
1921
* Fixed `Archive.filesize` (#137)
@@ -25,7 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2527

2628
## [1.0.0] - 2021-10-09
2729

28-
* using libzim 7.x
30+
* using libzim 7.0.0
2931
* Python 3.9 support
3032
* [breaking] Using new libzim 7-based API for both reader and writer
3133
* No more namespaces

libzim/libzim.pyx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,8 @@ cdef class _Creator:
303303
The item to add to the file
304304
Raises
305305
------
306+
RuntimeError
307+
If an Item exists with the same path
306308
RuntimeError
307309
If the ZimCreator was already finalized"""
308310
if not self._started:
@@ -317,7 +319,12 @@ cdef class _Creator:
317319
def add_metadata(self, str name: str, bytes content: bytes, str mimetype: str):
318320
"""Add metadata entry to Archive
319321
320-
https://wiki.openzim.org/wiki/Metadata"""
322+
https://wiki.openzim.org/wiki/Metadata
323+
324+
Raises
325+
------
326+
RuntimeError
327+
If a Metadata exists with the same name"""
321328
if not self._started:
322329
raise RuntimeError("Creator not started")
323330

@@ -331,6 +338,11 @@ cdef class _Creator:
331338
"""Add redirection entry to Archive
332339
333340
https://wiki.openzim.org/wiki/ZIM_file_format#Redirect_Entry
341+
342+
Raises
343+
------
344+
RuntimeError
345+
If a Rediction exists with the same path
334346
"""
335347
if not self._started:
336348
raise RuntimeError("Creator not started")

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = [ "setuptools >= 35.0.2", "wheel >= 0.29.0", "twine", "cython >= 0.29.26,<3.0" ]
2+
requires = [ "setuptools >= 35.0.2", "wheel >= 0.29.0", "twine", "cython >= 0.29.28,<3.0" ]
33
build-backend = "setuptools.build_meta"
44

55
[tool.black]

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ invoke>=1.5,<2.0
55
coverage>=5.0,<7.0
66
pytest>=6.2,<7.0
77
pytest-cov>=2.10,<4.0
8-
Cython>=0.29.26
8+
Cython>=0.29.28

tasks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515

1616
@task
17-
def download_libzim(c, version="7.1.0"):
17+
def download_libzim(c, version="7.2.2"):
1818
"""download C++ libzim binary"""
1919

2020
if platform.machine() != "x86_64" or platform.system() not in ("Linux", "Darwin"):

tests/test_libzim_creator.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,6 @@ def test_creator_metadata(fpath, lipsum_item):
391391
"_videos:no;_details:yes;_ftindex:yes",
392392
"Flavour": "nopic",
393393
"Source": "https://en.wikipedia.org/",
394-
"Counter": "image/jpeg=5;image/gif=3;image/png=2",
395394
"Scraper": "sotoki 1.2.3",
396395
}
397396

@@ -417,12 +416,25 @@ def test_creator_metadata(fpath, lipsum_item):
417416
assert zim.get_metadata(name).decode("UTF-8") == value
418417

419418

420-
def test_creator_metadata_nooverwrite(fpath, lipsum_item):
419+
def test_creator_metadata_overwrite(fpath, lipsum_item, favicon_data):
420+
"""re-adding an Entry (even Metadata) now raises an exception (libzim 7.2+)"""
421421
with Creator(fpath) as c:
422422
c.add_item(lipsum_item)
423+
with pytest.raises(RuntimeError, match="Impossible to add"):
424+
c.add_item(lipsum_item)
425+
423426
c.add_metadata("Key", "first")
424-
# re-setting a value prints a warning and ignore it
425-
c.add_metadata("Key", "second")
427+
with pytest.raises(RuntimeError, match="Impossible to add"):
428+
c.add_metadata("Key", "second")
429+
430+
c.add_redirection("home", lipsum_item.get_path(), "Home", {})
431+
with pytest.raises(RuntimeError, match="Impossible to add"):
432+
c.add_redirection("home", lipsum_item.get_path(), "Home again", {})
433+
434+
c.add_illustration(48, favicon_data)
435+
# this currently segfaults but it should not
436+
# with pytest.raises(RuntimeError, match="Impossible to add"):
437+
# c.add_illustration(48, favicon_data)
426438
zim = Archive(fpath)
427439
assert zim.get_metadata("Key").decode("UTF-8") == "first"
428440

0 commit comments

Comments
 (0)