Skip to content

Commit 63eff4a

Browse files
authored
Merge pull request #234 from openzim/libzim_9.4.0
Move to libzim 9.4.0
2 parents e6e0f13 + ff328b0 commit 63eff4a

File tree

12 files changed

+80
-119
lines changed

12 files changed

+80
-119
lines changed

.github/workflows/CI-wheels.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
- main
88

99
env:
10-
LIBZIM_DL_VERSION: "9.3.0-1"
10+
LIBZIM_DL_VERSION: "9.4.0-1"
1111
MACOSX_DEPLOYMENT_TARGET: "13.0"
1212
CIBW_ENVIRONMENT_PASS_LINUX: "LIBZIM_DL_VERSION"
1313
CIBW_BUILD_VERBOSITY: "3"

.github/workflows/Publish.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- published
77

88
env:
9-
LIBZIM_DL_VERSION: "9.3.0-1"
9+
LIBZIM_DL_VERSION: "9.4.0-1"
1010
MACOSX_DEPLOYMENT_TARGET: "13.0"
1111
CIBW_ENVIRONMENT_PASS_LINUX: "LIBZIM_DL_VERSION"
1212
# APPLE_SIGNING_KEYCHAIN_PATH set in prepare keychain step

.github/workflows/QA.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: QA
22
on: [push]
33

44
env:
5-
LIBZIM_DL_VERSION: "9.3.0-1"
5+
LIBZIM_DL_VERSION: "9.4.0-1"
66
MACOSX_DEPLOYMENT_TARGET: "13.0"
77

88
jobs:

.github/workflows/Tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Tests
22
on: [push]
33

44
env:
5-
LIBZIM_DL_VERSION: "9.3.0-1"
5+
LIBZIM_DL_VERSION: "9.4.0-1"
66
MACOSX_DEPLOYMENT_TARGET: "13.0"
77
# we want cython traces for coverage
88
PROFILE: "1"

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818
- Upgrade Github CI Actions
1919
- Run tests on minimum supported platforms + more recent stable ones
2020
- Fix various Cython warning and deprecation notices (#239)
21+
- libzim 9.4.0 Cache Control API
22+
- remove `Archive.dirent_lookup_cache_max_size`, does not exists anymore in libzim
23+
- move `Archive.cluster_cache_max_size` and `Archive.cluster_cache_current_size` to methods outside of `Archive` object: `get_cluster_cache_max_size`, `set_cluster_cache_max_size`, `get_cluster_cache_current_size` (size is now in bytes)
24+
- deprecate usage of `get_illustration_sizes()`
25+
2126

2227
## [3.7.0] - 2025-04-18
2328

libzim/libwrapper.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,9 @@ class Archive : public Wrapper<zim::Archive>
172172
FORWARD(bool, hasTitleIndex)
173173
FORWARD(bool, hasChecksum)
174174
FORWARD(bool, check)
175-
FORWARD(zim::size_type, getClusterCacheMaxSize)
176-
FORWARD(zim::size_type, getClusterCacheCurrentSize)
177-
FORWARD(void, setClusterCacheMaxSize)
178175
FORWARD(zim::size_type, getDirentCacheMaxSize)
179176
FORWARD(zim::size_type, getDirentCacheCurrentSize)
180177
FORWARD(void, setDirentCacheMaxSize)
181-
FORWARD(zim::size_type, getDirentLookupCacheMaxSize)
182-
FORWARD(void, setDirentLookupCacheMaxSize)
183178
};
184179

185180
class SearchResultSet : public Wrapper<zim::SearchResultSet>

libzim/libzim.pyx

Lines changed: 39 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import os
3939
import pathlib
4040
import sys
4141
import traceback
42+
import warnings
4243
from collections import OrderedDict
4344
from types import ModuleType
4445
from typing import Dict, Generator, Iterator, List, Optional, Set, TextIO, Tuple, Union
@@ -1304,9 +1305,18 @@ cdef class Archive:
13041305
def get_illustration_sizes(self) -> Set[pyint]:
13051306
"""Sizes for which an illustration is available (@1 scale only).
13061307

1308+
.. deprecated:: 3.8.0
1309+
Use :meth:`get_illustration_infos` instead for full illustration metadata
1310+
including width, height, and scale information.
1311+
13071312
Returns:
13081313
The set of available sizes of the illustration.
13091314
"""
1315+
warnings.warn(
1316+
"get_illustration_sizes() is deprecated, use get_illustration_infos() instead",
1317+
DeprecationWarning,
1318+
stacklevel=2
1319+
)
13101320
return self.c_archive.getIllustrationSizes()
13111321
13121322
def has_illustration(self, size: pyint = None) -> pybool:
@@ -1332,37 +1342,6 @@ cdef class Archive:
13321342
except RuntimeError as e:
13331343
raise KeyError(str(e))
13341344
1335-
@property
1336-
def cluster_cache_max_size(self) -> pyint:
1337-
"""Maximum size of the cluster cache.
1338-
1339-
Returns:
1340-
(int): maximum number of clusters stored in the cache.
1341-
"""
1342-
return self.c_archive.getClusterCacheMaxSize()
1343-
1344-
@cluster_cache_max_size.setter
1345-
def cluster_cache_max_size(self, nb_clusters: pyint):
1346-
"""Set the size of the cluster cache.
1347-
1348-
If the new size is lower than the number of currently stored clusters
1349-
some clusters will be dropped from cache to respect the new size.
1350-
1351-
Args:
1352-
nb_clusters (int): maximum number of clusters stored in the cache
1353-
"""
1354-
1355-
self.c_archive.setClusterCacheMaxSize(nb_clusters)
1356-
1357-
@property
1358-
def cluster_cache_current_size(self) -> pyint:
1359-
"""Size of the cluster cache.
1360-
1361-
Returns:
1362-
(int): number of clusters currently stored in the cache.
1363-
"""
1364-
return self.c_archive.getClusterCacheCurrentSize()
1365-
13661345
@property
13671346
def dirent_cache_max_size(self) -> pyint:
13681347
"""Maximum size of the dirent cache.
@@ -1393,36 +1372,38 @@ cdef class Archive:
13931372
"""
13941373
return self.c_archive.getDirentCacheCurrentSize()
13951374
1396-
@property
1397-
def dirent_lookup_cache_max_size(self) -> pyint:
1398-
"""Size of the dirent lookup cache.
1375+
def __repr__(self) -> str:
1376+
return f"{self.__class__.__name__}(filename={self.filename})"
13991377
1400-
The returned size returns the default size or the last set size.
1401-
This may not correspond to the actual size of the dirent lookup cache.
1402-
See set_dirent_lookup_cache_max_size for more information.
14031378
1404-
Returns:
1405-
(int): maximum number of sub ranges created in the lookup cache.
1406-
"""
1407-
return self.c_archive.getDirentLookupCacheMaxSize()
1379+
def get_cluster_cache_max_size() -> pyint:
1380+
"""Get the maximum size of the cluster cache.
14081381

1409-
@dirent_lookup_cache_max_size.setter
1410-
def dirent_lookup_cache_max_size(self, nb_ranges: pyint):
1411-
"""Set the size of the dirent lookup cache.
1382+
Returns:
1383+
(int): the maximum memory size used by the cluster cache (in bytes).
1384+
"""
1385+
return zim.getClusterCacheMaxSize()
14121386
1413-
Contrary to other set_<foo>_cache_max_size, this method is useless
1414-
once the lookup cache is created.
1415-
The lookup cache is created at first access to a entry in the archive.
1416-
So this method must be called before any access to content (including metadata).
1417-
It is best to call this method first, just after the archive creation.
1387+
def set_cluster_cache_max_size(size_in_bytes: pyint):
1388+
"""Set the size of the cluster cache.
14181389

1419-
Args:
1420-
nb_ranges (int): maximum number of sub ranges created in the lookup cache.
1421-
"""
1422-
self.c_archive.setDirentLookupCacheMaxSize(nb_ranges)
1390+
If the new size is lower than the number of currently stored clusters
1391+
some clusters will be dropped from cache to respect the new size.
1392+
1393+
Args:
1394+
size_in_bytes (int): the memory limit (in bytes) for the cluster cache.
1395+
"""
1396+
1397+
zim.setClusterCacheMaxSize(size_in_bytes)
1398+
1399+
def get_cluster_cache_current_size() -> pyint:
1400+
"""Get the current size of the cluster cache.
1401+
1402+
Returns:
1403+
(int): the current memory size (in bytes) used by the cluster cache.
1404+
"""
1405+
return zim.getClusterCacheCurrentSize()
14231406
1424-
def __repr__(self) -> str:
1425-
return f"{self.__class__.__name__}(filename={self.filename})"
14261407
14271408
reader_module_doc = """libzim reader module
14281409

@@ -1442,6 +1423,9 @@ reader_public_objects = [
14421423
Archive,
14431424
Entry,
14441425
Item,
1426+
get_cluster_cache_max_size,
1427+
set_cluster_cache_max_size,
1428+
get_cluster_cache_current_size,
14451429
]
14461430
reader = create_module(reader_module_name, reader_module_doc, reader_public_objects)
14471431

libzim/reader.pyi

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,13 @@ class Archive:
7878
def has_illustration(self, size: int | None = None) -> bool: ...
7979
def get_illustration_item(self, size: int | None = None) -> Item: ...
8080
@property
81-
def cluster_cache_max_size(self) -> int: ...
82-
@cluster_cache_max_size.setter
83-
def cluster_cache_max_size(self, nb_clusters: int): ...
84-
@property
85-
def cluster_cache_current_size(self) -> int: ...
86-
@property
8781
def dirent_cache_max_size(self) -> int: ...
8882
@dirent_cache_max_size.setter
8983
def dirent_cache_max_size(self, nb_dirents: int): ...
9084
@property
9185
def dirent_cache_current_size(self) -> int: ...
92-
@property
93-
def dirent_lookup_cache_max_size(self) -> int: ...
94-
@dirent_lookup_cache_max_size.setter
95-
def dirent_lookup_cache_max_size(self, nb_ranges: int): ...
9686
def __repr__(self) -> str: ...
87+
88+
def get_cluster_cache_max_size() -> int: ...
89+
def set_cluster_cache_max_size(nb_clusters: int): ...
90+
def get_cluster_cache_current_size() -> int: ...

libzim/zim.pxd

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,9 @@ cdef extern from "libwrapper.h" namespace "wrapper":
178178
bool hasChecksum() except +
179179
bool check() except +
180180

181-
uint64_t getClusterCacheMaxSize() except +
182-
uint64_t getClusterCacheCurrentSize() except +
183-
void setClusterCacheMaxSize(uint64_t nbClusters) except +
184181
uint64_t getDirentCacheMaxSize() except +
185182
uint64_t getDirentCacheCurrentSize() except +
186183
void setDirentCacheMaxSize(uint64_t nbDirents) except +
187-
uint64_t getDirentLookupCacheMaxSize() except +
188-
void setDirentLookupCacheMaxSize(uint64_t nbRanges) except +
189184

190185
cdef cppclass Searcher:
191186
Searcher()
@@ -233,3 +228,8 @@ cdef extern from "libwrapper.h" namespace "wrapper":
233228

234229
cdef extern from "zim/version.h" namespace "zim":
235230
cdef vector[pair[string, string]] getVersions()
231+
232+
cdef extern from "zim/archive.h" namespace "zim":
233+
cdef uint64_t getClusterCacheMaxSize() except +
234+
cdef uint64_t getClusterCacheCurrentSize() except +
235+
cdef void setClusterCacheMaxSize(uint64_t sizeInB) except +

setup.py

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

3232

3333
class Config:
34-
libzim_dl_version: str = os.getenv("LIBZIM_DL_VERSION", "9.3.0-1")
34+
libzim_dl_version: str = os.getenv("LIBZIM_DL_VERSION", "9.4.0-1")
3535
use_system_libzim: bool = bool(os.getenv("USE_SYSTEM_LIBZIM") or False)
3636
download_libzim: bool = not bool(os.getenv("DONT_DOWNLOAD_LIBZIM") or False)
3737

0 commit comments

Comments
 (0)