Skip to content

Commit 02510b1

Browse files
Merge remote-tracking branch 'upstream/main'
2 parents abea743 + f8d0a68 commit 02510b1

File tree

5 files changed

+54
-4
lines changed

5 files changed

+54
-4
lines changed

docker-compose.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# This is the final, recommended configuration.
2+
# It builds a single, self-contained image with all dependencies.
3+
4+
services:
5+
pdf2zh:
6+
build:
7+
context: .
8+
# All the setup steps are now part of a one-time build process.
9+
dockerfile_inline: |
10+
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
11+
12+
WORKDIR /app
13+
14+
# 1. Install system-level dependencies FIRST.
15+
# This is what solves the "libGL.so.1 not found" error.
16+
RUN apt-get update && \
17+
apt-get install --no-install-recommends -y libgl1 libglib2.0-0 libxext6 libsm6 libxrender1 && \
18+
rm -rf /var/lib/apt/lists/*
19+
20+
# 2. Copy only the dependency file and install Python packages.
21+
# This layer is cached and only re-runs if pyproject.toml changes.
22+
COPY pyproject.toml .
23+
RUN uv pip install --system --no-cache -r pyproject.toml
24+
25+
# 3. Copy the rest of your application code.
26+
COPY . .
27+
28+
# 4. Install the local package and perform final updates/warmups.
29+
RUN uv pip install --system --no-cache . && \
30+
uv pip install --system --no-cache -U "babeldoc<0.3.0" "pymupdf<1.25.3" "pdfminer-six==20250416" && \
31+
babeldoc --warmup
32+
33+
# The rest of the configuration is for RUNNING the built image.
34+
ports:
35+
- "7860:7860"
36+
37+
environment:
38+
- PYTHONUNBUFFERED=1
39+
# The UV_LINK_MODE warning happens during build, so we can set it there if needed,
40+
# but it's generally harmless.
41+
42+
command: ["pdf2zh", "-i"]
43+
44+
# Optional: Mount a volume for persistent data I/O if needed
45+
# volumes:
46+
# - ./data:/app/data
47+
48+
stdin_open: true
49+
tty: true

pdf2zh/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33

44
log = logging.getLogger(__name__)
55

6-
__version__ = "1.9.9"
6+
__version__ = "1.9.10"
77
__author__ = "Byaidu"
88
__all__ = ["translate", "translate_stream"]

pdf2zh/high_level.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def translate_patch(
126126
callback(progress)
127127
page.pageno = pageno
128128
pix = doc_zh[page.pageno].get_pixmap()
129-
image = np.fromstring(pix.samples, np.uint8).reshape(
129+
image = np.frombuffer(pix.samples, np.uint8).reshape(
130130
pix.height, pix.width, 3
131131
)[:, :, ::-1]
132132
page_layout = model.predict(image, imgsz=int(pix.height / 32) * 32)[0]

pdf2zh/translator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ def do_translate(self, text):
287287
"target_lang": self.lang_out,
288288
"text": text,
289289
},
290+
verify=False, # noqa: S506
290291
)
291292
response.raise_for_status()
292293
return response.json()["data"]

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "pdf2zh"
3-
version = "1.9.9"
3+
version = "1.9.10"
44
description = "Latex PDF Translator"
55
authors = [{ name = "Byaidu", email = "byaidux@gmail.com" }]
66
license = "AGPL-3.0"
@@ -77,7 +77,7 @@ max-line-length = 88
7777

7878

7979
[bumpver]
80-
current_version = "1.9.9"
80+
current_version = "1.9.10"
8181
version_pattern = "MAJOR.MINOR.PATCH[.PYTAGNUM]"
8282

8383
[bumpver.file_patterns]

0 commit comments

Comments
 (0)