From 09e0da006b0bc6adeffdaf06461a3b66c0c97482 Mon Sep 17 00:00:00 2001 From: Ghislain Vaillant Date: Mon, 12 Aug 2024 14:33:47 +0200 Subject: [PATCH] Use plyvel for the leveldb backend Rationales: - quickumls fails to install on Python 3.12 due to py-leveldb - py-leveldb looks unmaintained and is unlikely to receive support for Python 3.12 - plyvel provides a suitable replacement and is compatible with Python 3.12 onwards Closes #98 --- quickumls/toolbox.py | 14 +++++++------- requirements.txt | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/quickumls/toolbox.py b/quickumls/toolbox.py index 3c7ea34..b24c1f0 100644 --- a/quickumls/toolbox.py +++ b/quickumls/toolbox.py @@ -12,7 +12,7 @@ # installed modules import numpy -import leveldb +import plyvel try: import unqlite UNQLITE_AVAILABLE = True @@ -240,12 +240,12 @@ def __init__(self, path, database_backend='leveldb'): self.semtypes_db_put = self.semtypes_db.store self.semtypes_db_get = self.semtypes_db.fetch elif database_backend == 'leveldb': - self.cui_db = leveldb.LevelDB(os.path.join(path, 'cui.leveldb')) - self.cui_db_put = self.cui_db.Put - self.cui_db_get = self.cui_db.Get - self.semtypes_db = leveldb.LevelDB(os.path.join(path, 'semtypes.leveldb')) - self.semtypes_db_put = self.semtypes_db.Put - self.semtypes_db_get = self.semtypes_db.Get + self.cui_db = plyvel.DB(os.path.join(path, 'cui.leveldb'), create_if_missing=True) + self.cui_db_put = self.cui_db.put + self.cui_db_get = self.cui_db.get + self.semtypes_db = plyvel.DB(os.path.join(path, 'semtypes.leveldb'), create_if_missing=True) + self.semtypes_db_put = self.semtypes_db.put + self.semtypes_db_get = self.semtypes_db.get else: raise ValueError(f'database_backend {database_backend} not recognized') diff --git a/requirements.txt b/requirements.txt index bae55f1..d66b91f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -leveldb>=0.193 +plyvel>=1.5.1 numpy>=1.8.2 spacy>=3.0.6 unidecode>=0.4.19