Migrate from bsddb3 to berkeleydb
Following official documentation, move away from bsddb3 to berkeleydb. https://www.jcea.es/programacion/pybsddb.htm Main change: key and values are now bytes and not strings. The code diff is really simple because all operations on keys/values is done from elixir/data.py and that works fine with both bytes and strings (it does explicit casting).
This commit is contained in:
parent
7df3543b2a
commit
5e8eb77912
4 changed files with 12 additions and 13 deletions
|
|
@ -11,9 +11,8 @@ RUN \
|
|||
|
||||
WORKDIR /build/
|
||||
|
||||
# TODO switch to berkeleydb
|
||||
# NOTE wheel version MUST be sycnhronized with requirements.txt
|
||||
RUN pip wheel bsddb3==6.2.9
|
||||
RUN pip wheel berkeleydb==18.1.10
|
||||
|
||||
FROM debian:bookworm
|
||||
|
||||
|
|
@ -37,11 +36,11 @@ COPY . /usr/local/elixir/
|
|||
|
||||
WORKDIR /usr/local/elixir/
|
||||
|
||||
COPY --from=build /build/bsddb3-6.2.9-*.whl /tmp/build/
|
||||
COPY --from=build /build/berkeleydb-*.whl /tmp/build/
|
||||
|
||||
RUN python3 -m venv venv && \
|
||||
. ./venv/bin/activate && \
|
||||
pip install /tmp/build/bsddb3-6.2.9-*.whl && \
|
||||
pip install /tmp/build/berkeleydb-*.whl && \
|
||||
pip install -r requirements.txt
|
||||
|
||||
RUN mkdir -p /srv/elixir-data/
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import sys
|
|||
import os
|
||||
import json
|
||||
from urllib import parse
|
||||
from bsddb3.db import DB_SET_RANGE
|
||||
from berkeleydb.db import DB_SET_RANGE
|
||||
import falcon
|
||||
|
||||
from .lib import autoBytes, validFamily
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with Elixir. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import bsddb3
|
||||
import berkeleydb
|
||||
import re
|
||||
from .lib import autoBytes
|
||||
import os
|
||||
|
|
@ -147,15 +147,15 @@ class RefList:
|
|||
class BsdDB:
|
||||
def __init__(self, filename, readonly, contentType, shared=False):
|
||||
self.filename = filename
|
||||
self.db = bsddb3.db.DB()
|
||||
flags = bsddb3.db.DB_THREAD if shared else 0
|
||||
self.db = berkeleydb.db.DB()
|
||||
flags = berkeleydb.db.DB_THREAD if shared else 0
|
||||
|
||||
if readonly:
|
||||
flags |= bsddb3.db.DB_RDONLY
|
||||
flags |= berkeleydb.db.DB_RDONLY
|
||||
self.db.open(filename, flags=flags)
|
||||
else:
|
||||
flags |= bsddb3.db.DB_CREATE
|
||||
self.db.open(filename, flags=flags, mode=0o644, dbtype=bsddb3.db.DB_BTREE)
|
||||
flags |= berkeleydb.db.DB_CREATE
|
||||
self.db.open(filename, flags=flags, mode=0o644, dbtype=berkeleydb.db.DB_BTREE)
|
||||
self.ctype = contentType
|
||||
|
||||
def exists(self, key):
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ Pygments~=2.18.0
|
|||
Falcon @ git+https://github.com/falconry/falcon.git@cbca63dc7739720eab856f48b32f9e782438be7a
|
||||
pytest==7.2.1
|
||||
|
||||
# NOTE binary wheels of bsddb3 are not distributed - on Debian this may
|
||||
# NOTE binary wheels of berkeleydb are not distributed - on Debian this may
|
||||
# require installing build-essentials, python3-dev and libdb-dev
|
||||
# NOTE keep in sync with wheel version in the Dockerfile
|
||||
bsddb3==6.2.9
|
||||
berkeleydb==18.1.10
|
||||
|
|
|
|||
Loading…
Reference in a new issue