forked from Byaidu/PDFMathTranslate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6e8b40f
commit 1d803b2
Showing
19 changed files
with
5,519 additions
and
5,606 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
Oops, something went wrong.