Skip to content

Commit

Permalink
merge from main
Browse files Browse the repository at this point in the history
  • Loading branch information
hellofinch committed Jan 15, 2025
1 parent 6e8b40f commit 1d803b2
Show file tree
Hide file tree
Showing 19 changed files with 5,519 additions and 5,606 deletions.
104 changes: 52 additions & 52 deletions .github/workflows/python-build.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
name: Test and Build Python Package

on:
push:
pull_request:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11' # avoid bugs in new versions
cache: 'pip'
cache-dependency-path: pyproject.toml

- name: Install dependencies
run: |
pip3 install -U pip
pip3 install -e .[dev]
- name: Test - Unit Test
run: |
pytest .
- name: Test - Translate a PDF file with plain text only
run:
pdf2zh ./test/file/translate.cli.plain.text.pdf -o ./test/file

- name: Test - Translate a PDF file figure
run:
pdf2zh ./test/file/translate.cli.text.with.figure.pdf -o ./test/file

# - name: Test - Translate a PDF file with unknown font
# run:
# pdf2zh ./test/file/translate.cli.font.unknown.pdf

- name: Test - Start GUI and exit
run:
timeout 10 pdf2zh -i || code=$?; if [[ $code -ne 124 && $code -ne 0 ]]; then exit $code; fi

- name: Build as a package
run: python -m build

- name: Upload test results
uses: actions/upload-artifact@v4
with:
name: test-results
path: ./test/file/
name: Test and Build Python Package

on:
push:
pull_request:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11' # avoid bugs in new versions
cache: 'pip'
cache-dependency-path: pyproject.toml

- name: Install dependencies
run: |
pip3 install -U pip
pip3 install -e .[dev]
- name: Test - Unit Test
run: |
pytest .
- name: Test - Translate a PDF file with plain text only
run:
pdf2zh ./test/file/translate.cli.plain.text.pdf -o ./test/file

- name: Test - Translate a PDF file figure
run:
pdf2zh ./test/file/translate.cli.text.with.figure.pdf -o ./test/file

# - name: Test - Translate a PDF file with unknown font
# run:
# pdf2zh ./test/file/translate.cli.font.unknown.pdf

- name: Test - Start GUI and exit
run:
timeout 10 pdf2zh -i || code=$?; if [[ $code -ne 124 && $code -ne 0 ]]; then exit $code; fi

- name: Build as a package
run: python -m build

- name: Upload test results
uses: actions/upload-artifact@v4
with:
name: test-results
path: ./test/file/
52 changes: 26 additions & 26 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim

WORKDIR /app


EXPOSE 7860

ENV PYTHONUNBUFFERED=1

# Download all required fonts
ADD "https://github.com/satbyy/go-noto-universal/releases/download/v7.0/GoNotoKurrent-Regular.ttf" /app/
ADD "https://github.com/timelic/source-han-serif/releases/download/main/SourceHanSerifCN-Regular.ttf" /app/
ADD "https://github.com/timelic/source-han-serif/releases/download/main/SourceHanSerifTW-Regular.ttf" /app/
ADD "https://github.com/timelic/source-han-serif/releases/download/main/SourceHanSerifJP-Regular.ttf" /app/
ADD "https://github.com/timelic/source-han-serif/releases/download/main/SourceHanSerifKR-Regular.ttf" /app/

RUN apt-get update && \
apt-get install --no-install-recommends -y libgl1 && \
rm -rf /var/lib/apt/lists/* && uv pip install --system --no-cache huggingface-hub && \
python3 -c "from huggingface_hub import hf_hub_download; hf_hub_download('wybxc/DocLayout-YOLO-DocStructBench-onnx','doclayout_yolo_docstructbench_imgsz1024.onnx');"

COPY . .

RUN uv pip install --system --no-cache .

CMD ["pdf2zh", "-i"]
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim

WORKDIR /app


EXPOSE 7860

ENV PYTHONUNBUFFERED=1

# Download all required fonts
ADD "https://github.com/satbyy/go-noto-universal/releases/download/v7.0/GoNotoKurrent-Regular.ttf" /app/
ADD "https://github.com/timelic/source-han-serif/releases/download/main/SourceHanSerifCN-Regular.ttf" /app/
ADD "https://github.com/timelic/source-han-serif/releases/download/main/SourceHanSerifTW-Regular.ttf" /app/
ADD "https://github.com/timelic/source-han-serif/releases/download/main/SourceHanSerifJP-Regular.ttf" /app/
ADD "https://github.com/timelic/source-han-serif/releases/download/main/SourceHanSerifKR-Regular.ttf" /app/

RUN apt-get update && \
apt-get install --no-install-recommends -y libgl1 && \
rm -rf /var/lib/apt/lists/* && uv pip install --system --no-cache huggingface-hub && \
python3 -c "from huggingface_hub import hf_hub_download; hf_hub_download('wybxc/DocLayout-YOLO-DocStructBench-onnx','doclayout_yolo_docstructbench_imgsz1024.onnx');"

COPY . .

RUN uv pip install --system --no-cache .

CMD ["pdf2zh", "-i"]
Loading

0 comments on commit 1d803b2

Please sign in to comment.