Skip to content

armgit / mwmbl

Public Imported from GitHub
0

An open source, non-profit web search engine

Fix mwmbl script

Daoud Clarkedd676c54edcb
diff --git a/Dockerfile b/Dockerfile
index 38c968e..d970ca5 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -5,7 +5,7 @@ WORKDIR /front-end
RUN npm install && npm run build
-FROM python:3.11.12-bullseye as base
+FROM python:3.11.12-bookworm as base
ENV PYTHONFAULTHANDLER=1 \
PYTHONHASHSEED=random \
@@ -21,8 +21,9 @@ ENV PIP_DEFAULT_TIMEOUT=100 \
# Install Rust toolchain (required by maturin to compile the mwmbl_rank extension)
# Install clang/libclang-dev for bindgen (used by xgboost_lib-sys)
+# Install patchelf so maturin can bundle libxgboost.so into the wheel RPATH
RUN apt-get update && \
- apt-get install -y clang libclang-dev && \
+ apt-get install -y clang libclang-dev patchelf && \
rm -rf /var/lib/apt/lists/*
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
@@ -46,6 +47,12 @@ COPY mwmbl_rank /app/mwmbl_rank
RUN /venv/bin/pip install pip wheel --upgrade && \
/venv/bin/pip install .
+# Copy libxgboost.so (prebuilt by the xgb crate) into the mwmbl_rank package
+# directory and patch the extension's RPATH so it finds the library at runtime.
+RUN SODIR=/venv/lib/python3.11/site-packages/mwmbl_rank && \
+ cp /app/mwmbl_rank/target/release/deps/libxgboost.so "$SODIR/" && \
+ patchelf --set-rpath '$ORIGIN' "$SODIR/mwmbl_rank.cpython-311-x86_64-linux-gnu.so"
+
FROM base as final
RUN apt-get update && apt-get install -y postgresql-client && rm -rf /var/lib/apt/lists/*
diff --git a/pyproject.toml b/pyproject.toml
index fbc2f88..81c0412 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -73,6 +73,17 @@ fakeredis = "^2.30.1"
requires = ["maturin>=1.5,<2.0"]
build-backend = "maturin"
+# PEP 621 project metadata required by maturin to install entry point scripts.
+# [tool.poetry.scripts] is Poetry-specific and ignored by maturin.
+[project]
+name = "mwmbl"
+version = "0.1.0"
+requires-python = ">=3.11,<3.12"
+
+[project.scripts]
+mwmbl-tinysearchengine = "mwmbl.main:run"
+mwmbl-crawl = "mwmbl.crawl:run"
+
[tool.maturin]
python-source = "."
module-name = "mwmbl_rank"