From d11ff90ad0fb2d8d7a20d60238e816f2aa5f5ccf Mon Sep 17 00:00:00 2001 From: Rongxin Date: Sun, 8 Jun 2025 19:35:29 +0800 Subject: [PATCH 1/3] fix: numpy compatibility error --- pdf2zh/high_level.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pdf2zh/high_level.py b/pdf2zh/high_level.py index 69cb28583..b52ff8292 100644 --- a/pdf2zh/high_level.py +++ b/pdf2zh/high_level.py @@ -126,7 +126,7 @@ def translate_patch( callback(progress) page.pageno = pageno pix = doc_zh[page.pageno].get_pixmap() - image = np.fromstring(pix.samples, np.uint8).reshape( + image = np.frombuffer(pix.samples, np.uint8).reshape( pix.height, pix.width, 3 )[:, :, ::-1] page_layout = model.predict(image, imgsz=int(pix.height / 32) * 32)[0] From 346459ead13bdde2dc72d766541943f8d49f2c09 Mon Sep 17 00:00:00 2001 From: Rongxin Date: Sun, 8 Jun 2025 19:35:32 +0800 Subject: [PATCH 2/3] feat: support docker compose --- docker-compose.yml | 49 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..1e7c73e2e --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,49 @@ +# This is the final, recommended configuration. +# It builds a single, self-contained image with all dependencies. + +services: + pdf2zh: + build: + context: . + # All the setup steps are now part of a one-time build process. + dockerfile_inline: | + FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim + + WORKDIR /app + + # 1. Install system-level dependencies FIRST. + # This is what solves the "libGL.so.1 not found" error. + RUN apt-get update && \ + apt-get install --no-install-recommends -y libgl1 libglib2.0-0 libxext6 libsm6 libxrender1 && \ + rm -rf /var/lib/apt/lists/* + + # 2. Copy only the dependency file and install Python packages. + # This layer is cached and only re-runs if pyproject.toml changes. + COPY pyproject.toml . + RUN uv pip install --system --no-cache -r pyproject.toml + + # 3. Copy the rest of your application code. + COPY . . + + # 4. Install the local package and perform final updates/warmups. + RUN uv pip install --system --no-cache . && \ + uv pip install --system --no-cache -U "babeldoc<0.3.0" "pymupdf<1.25.3" "pdfminer-six==20250416" && \ + babeldoc --warmup + + # The rest of the configuration is for RUNNING the built image. + ports: + - "7860:7860" + + environment: + - PYTHONUNBUFFERED=1 + # The UV_LINK_MODE warning happens during build, so we can set it there if needed, + # but it's generally harmless. + + command: ["pdf2zh", "-i"] + + # Optional: Mount a volume for persistent data I/O if needed + # volumes: + # - ./data:/app/data + + stdin_open: true + tty: true \ No newline at end of file From 8b92181e710cc60ab856a748a99ba30ba74abc99 Mon Sep 17 00:00:00 2001 From: awwaawwa <8493196+awwaawwa@users.noreply.github.com> Date: Sun, 8 Jun 2025 20:02:37 +0800 Subject: [PATCH 3/3] chore: bump version to 1.9.10 --- pdf2zh/__init__.py | 2 +- pyproject.toml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pdf2zh/__init__.py b/pdf2zh/__init__.py index 634a3274c..80eedd451 100644 --- a/pdf2zh/__init__.py +++ b/pdf2zh/__init__.py @@ -3,6 +3,6 @@ log = logging.getLogger(__name__) -__version__ = "1.9.9" +__version__ = "1.9.10" __author__ = "Byaidu" __all__ = ["translate", "translate_stream"] diff --git a/pyproject.toml b/pyproject.toml index bf94fa7a1..0c40aff58 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "pdf2zh" -version = "1.9.9" +version = "1.9.10" description = "Latex PDF Translator" authors = [{ name = "Byaidu", email = "byaidux@gmail.com" }] license = "AGPL-3.0" @@ -77,7 +77,7 @@ max-line-length = 88 [bumpver] -current_version = "1.9.9" +current_version = "1.9.10" version_pattern = "MAJOR.MINOR.PATCH[.PYTAGNUM]" [bumpver.file_patterns]