Spaces:
Paused
Paused
root Claude commited on
Commit ·
bdc4bf7
1
Parent(s): d46c826
更新项目配置和依赖
Browse files- 规范化文件行结束符(Unix风格)
- 更新Docker配置和启动脚本
- 更新项目依赖配置文件
- 完善JupyterLab登录页面配置
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- .gitattributes +35 -35
- Dockerfile +110 -110
- README.md +15 -15
- login.html +67 -67
- on_startup.sh +4 -4
- pdftranslate_web/pdftranslate-mcp-server/config.ini +4 -4
- pdftranslate_web/pyproject.toml +174 -174
- pdftranslate_web/pyproject_scnet.toml +176 -176
- requirements.txt +3 -3
- start_server.sh +19 -19
.gitattributes
CHANGED
|
@@ -1,35 +1,35 @@
|
|
| 1 |
-
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
-
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
-
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
-
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
-
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
-
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
-
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
-
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
-
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
-
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
-
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
-
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
-
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
-
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
-
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
-
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
-
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
-
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
-
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
-
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
-
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
-
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
-
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
-
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
-
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
-
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
-
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
-
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
-
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
-
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
-
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
-
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
-
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
-
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
-
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
Dockerfile
CHANGED
|
@@ -1,110 +1,110 @@
|
|
| 1 |
-
FROM modelscope-registry.us-west-1.cr.aliyuncs.com/modelscope-repo/modelscope:ubuntu22.04-py311-torch2.3.1-1.28.0
|
| 2 |
-
|
| 3 |
-
ENV DEBIAN_FRONTEND=noninteractive \
|
| 4 |
-
TZ=Asia/Shanghai
|
| 5 |
-
|
| 6 |
-
# Remove any third-party apt sources and install basic utilities
|
| 7 |
-
RUN rm -f /etc/apt/sources.list.d/*.list && \
|
| 8 |
-
apt-get update && apt-get install -y --no-install-recommends \
|
| 9 |
-
curl \
|
| 10 |
-
ca-certificates \
|
| 11 |
-
sudo \
|
| 12 |
-
git \
|
| 13 |
-
wget \
|
| 14 |
-
procps \
|
| 15 |
-
git-lfs \
|
| 16 |
-
zip \
|
| 17 |
-
unzip \
|
| 18 |
-
htop \
|
| 19 |
-
vim \
|
| 20 |
-
nano \
|
| 21 |
-
bzip2 \
|
| 22 |
-
libx11-6 \
|
| 23 |
-
build-essential \
|
| 24 |
-
libsndfile-dev \
|
| 25 |
-
software-properties-common \
|
| 26 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 27 |
-
|
| 28 |
-
# Add cloudflare gpg key
|
| 29 |
-
RUN mkdir -p --mode=0755 /usr/share/keyrings && \
|
| 30 |
-
curl -fsSL https://pkg.cloudflare.com/cloudflare-main.gpg | tee /usr/share/keyrings/cloudflare-main.gpg >/dev/null
|
| 31 |
-
|
| 32 |
-
# Add this repo to your apt repositories
|
| 33 |
-
RUN echo 'deb [signed-by=/usr/share/keyrings/cloudflare-main.gpg] https://pkg.cloudflare.com/cloudflared any main' | tee /etc/apt/sources.list.d/cloudflared.list
|
| 34 |
-
|
| 35 |
-
# install cloudflared
|
| 36 |
-
RUN apt-get update && apt-get install -y cloudflared && rm -rf /var/lib/apt/lists/*
|
| 37 |
-
|
| 38 |
-
# Install Node.js for Jupyter extensions
|
| 39 |
-
RUN curl -sL https://deb.nodesource.com/setup_21.x | bash - && \
|
| 40 |
-
apt-get install -y nodejs && \
|
| 41 |
-
npm install -g configurable-http-proxy
|
| 42 |
-
|
| 43 |
-
# Define error handling function and install Claude Code CLI
|
| 44 |
-
RUN handle_error() { echo "错误: $1" >&2; exit 1; } && \
|
| 45 |
-
npm install -g @anthropic-ai/claude-code || handle_error "安装Claude Code CLI失败"
|
| 46 |
-
|
| 47 |
-
# Create a working directory
|
| 48 |
-
WORKDIR /app
|
| 49 |
-
|
| 50 |
-
# Create a non-root user and switch to it
|
| 51 |
-
RUN adduser --disabled-password --gecos '' --shell /bin/bash user \
|
| 52 |
-
&& chown -R user:user /app
|
| 53 |
-
RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
|
| 54 |
-
USER user
|
| 55 |
-
|
| 56 |
-
# All users can use /home/user as their home directory
|
| 57 |
-
ENV HOME=/home/user
|
| 58 |
-
RUN mkdir $HOME/.cache $HOME/.config \
|
| 59 |
-
&& chmod -R 777 $HOME
|
| 60 |
-
|
| 61 |
-
# Set up the Conda environment with Python 3.11
|
| 62 |
-
ENV CONDA_AUTO_UPDATE_CONDA=false \
|
| 63 |
-
PATH=$HOME/miniconda/bin:$PATH
|
| 64 |
-
RUN curl -sLo ~/miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-py311_23.5.2-0-Linux-x86_64.sh \
|
| 65 |
-
&& chmod +x ~/miniconda.sh \
|
| 66 |
-
&& ~/miniconda.sh -b -p ~/miniconda \
|
| 67 |
-
&& rm ~/miniconda.sh \
|
| 68 |
-
&& conda clean -ya
|
| 69 |
-
|
| 70 |
-
WORKDIR $HOME/app
|
| 71 |
-
|
| 72 |
-
#######################################
|
| 73 |
-
# Start root user section
|
| 74 |
-
#######################################
|
| 75 |
-
|
| 76 |
-
USER root
|
| 77 |
-
|
| 78 |
-
# Create data directory
|
| 79 |
-
RUN mkdir /data && chown user:user /data
|
| 80 |
-
|
| 81 |
-
#######################################
|
| 82 |
-
# End root user section
|
| 83 |
-
#######################################
|
| 84 |
-
|
| 85 |
-
USER user
|
| 86 |
-
|
| 87 |
-
# Install Python packages using conda and pip
|
| 88 |
-
RUN conda install -c conda-forge python=3.11 && \
|
| 89 |
-
pip install --no-cache-dir --upgrade pip
|
| 90 |
-
|
| 91 |
-
# Copy requirements and install Python packages
|
| 92 |
-
COPY --chown=user requirements.txt $HOME/app/
|
| 93 |
-
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 94 |
-
|
| 95 |
-
# Copy the current directory contents into the container
|
| 96 |
-
COPY --chown=user . $HOME/app
|
| 97 |
-
|
| 98 |
-
RUN chmod +x start_server.sh
|
| 99 |
-
|
| 100 |
-
# Set environment variables
|
| 101 |
-
ENV PYTHONUNBUFFERED=1 \
|
| 102 |
-
GRADIO_ALLOW_FLAGGING=never \
|
| 103 |
-
GRADIO_NUM_PORTS=1 \
|
| 104 |
-
GRADIO_SERVER_NAME=0.0.0.0 \
|
| 105 |
-
GRADIO_THEME=huggingface \
|
| 106 |
-
SYSTEM=spaces \
|
| 107 |
-
SHELL=/bin/bash \
|
| 108 |
-
JUPYTER_TOKEN=huggingface
|
| 109 |
-
|
| 110 |
-
CMD ["./start_server.sh"]
|
|
|
|
| 1 |
+
FROM modelscope-registry.us-west-1.cr.aliyuncs.com/modelscope-repo/modelscope:ubuntu22.04-py311-torch2.3.1-1.28.0
|
| 2 |
+
|
| 3 |
+
ENV DEBIAN_FRONTEND=noninteractive \
|
| 4 |
+
TZ=Asia/Shanghai
|
| 5 |
+
|
| 6 |
+
# Remove any third-party apt sources and install basic utilities
|
| 7 |
+
RUN rm -f /etc/apt/sources.list.d/*.list && \
|
| 8 |
+
apt-get update && apt-get install -y --no-install-recommends \
|
| 9 |
+
curl \
|
| 10 |
+
ca-certificates \
|
| 11 |
+
sudo \
|
| 12 |
+
git \
|
| 13 |
+
wget \
|
| 14 |
+
procps \
|
| 15 |
+
git-lfs \
|
| 16 |
+
zip \
|
| 17 |
+
unzip \
|
| 18 |
+
htop \
|
| 19 |
+
vim \
|
| 20 |
+
nano \
|
| 21 |
+
bzip2 \
|
| 22 |
+
libx11-6 \
|
| 23 |
+
build-essential \
|
| 24 |
+
libsndfile-dev \
|
| 25 |
+
software-properties-common \
|
| 26 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 27 |
+
|
| 28 |
+
# Add cloudflare gpg key
|
| 29 |
+
RUN mkdir -p --mode=0755 /usr/share/keyrings && \
|
| 30 |
+
curl -fsSL https://pkg.cloudflare.com/cloudflare-main.gpg | tee /usr/share/keyrings/cloudflare-main.gpg >/dev/null
|
| 31 |
+
|
| 32 |
+
# Add this repo to your apt repositories
|
| 33 |
+
RUN echo 'deb [signed-by=/usr/share/keyrings/cloudflare-main.gpg] https://pkg.cloudflare.com/cloudflared any main' | tee /etc/apt/sources.list.d/cloudflared.list
|
| 34 |
+
|
| 35 |
+
# install cloudflared
|
| 36 |
+
RUN apt-get update && apt-get install -y cloudflared && rm -rf /var/lib/apt/lists/*
|
| 37 |
+
|
| 38 |
+
# Install Node.js for Jupyter extensions
|
| 39 |
+
RUN curl -sL https://deb.nodesource.com/setup_21.x | bash - && \
|
| 40 |
+
apt-get install -y nodejs && \
|
| 41 |
+
npm install -g configurable-http-proxy
|
| 42 |
+
|
| 43 |
+
# Define error handling function and install Claude Code CLI
|
| 44 |
+
RUN handle_error() { echo "错误: $1" >&2; exit 1; } && \
|
| 45 |
+
npm install -g @anthropic-ai/claude-code || handle_error "安装Claude Code CLI失败"
|
| 46 |
+
|
| 47 |
+
# Create a working directory
|
| 48 |
+
WORKDIR /app
|
| 49 |
+
|
| 50 |
+
# Create a non-root user and switch to it
|
| 51 |
+
RUN adduser --disabled-password --gecos '' --shell /bin/bash user \
|
| 52 |
+
&& chown -R user:user /app
|
| 53 |
+
RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
|
| 54 |
+
USER user
|
| 55 |
+
|
| 56 |
+
# All users can use /home/user as their home directory
|
| 57 |
+
ENV HOME=/home/user
|
| 58 |
+
RUN mkdir $HOME/.cache $HOME/.config \
|
| 59 |
+
&& chmod -R 777 $HOME
|
| 60 |
+
|
| 61 |
+
# Set up the Conda environment with Python 3.11
|
| 62 |
+
ENV CONDA_AUTO_UPDATE_CONDA=false \
|
| 63 |
+
PATH=$HOME/miniconda/bin:$PATH
|
| 64 |
+
RUN curl -sLo ~/miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-py311_23.5.2-0-Linux-x86_64.sh \
|
| 65 |
+
&& chmod +x ~/miniconda.sh \
|
| 66 |
+
&& ~/miniconda.sh -b -p ~/miniconda \
|
| 67 |
+
&& rm ~/miniconda.sh \
|
| 68 |
+
&& conda clean -ya
|
| 69 |
+
|
| 70 |
+
WORKDIR $HOME/app
|
| 71 |
+
|
| 72 |
+
#######################################
|
| 73 |
+
# Start root user section
|
| 74 |
+
#######################################
|
| 75 |
+
|
| 76 |
+
USER root
|
| 77 |
+
|
| 78 |
+
# Create data directory
|
| 79 |
+
RUN mkdir /data && chown user:user /data
|
| 80 |
+
|
| 81 |
+
#######################################
|
| 82 |
+
# End root user section
|
| 83 |
+
#######################################
|
| 84 |
+
|
| 85 |
+
USER user
|
| 86 |
+
|
| 87 |
+
# Install Python packages using conda and pip
|
| 88 |
+
RUN conda install -c conda-forge python=3.11 && \
|
| 89 |
+
pip install --no-cache-dir --upgrade pip
|
| 90 |
+
|
| 91 |
+
# Copy requirements and install Python packages
|
| 92 |
+
COPY --chown=user requirements.txt $HOME/app/
|
| 93 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 94 |
+
|
| 95 |
+
# Copy the current directory contents into the container
|
| 96 |
+
COPY --chown=user . $HOME/app
|
| 97 |
+
|
| 98 |
+
RUN chmod +x start_server.sh
|
| 99 |
+
|
| 100 |
+
# Set environment variables
|
| 101 |
+
ENV PYTHONUNBUFFERED=1 \
|
| 102 |
+
GRADIO_ALLOW_FLAGGING=never \
|
| 103 |
+
GRADIO_NUM_PORTS=1 \
|
| 104 |
+
GRADIO_SERVER_NAME=0.0.0.0 \
|
| 105 |
+
GRADIO_THEME=huggingface \
|
| 106 |
+
SYSTEM=spaces \
|
| 107 |
+
SHELL=/bin/bash \
|
| 108 |
+
JUPYTER_TOKEN=huggingface
|
| 109 |
+
|
| 110 |
+
CMD ["./start_server.sh"]
|
README.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
| 1 |
-
---
|
| 2 |
-
title: 20250801test
|
| 3 |
-
emoji: 💻🐳
|
| 4 |
-
colorFrom: gray
|
| 5 |
-
colorTo: green
|
| 6 |
-
sdk: docker
|
| 7 |
-
pinned: false
|
| 8 |
-
tags:
|
| 9 |
-
- jupyterlab
|
| 10 |
-
suggested_storage: small
|
| 11 |
-
license: apache-2.0
|
| 12 |
-
---
|
| 13 |
-
|
| 14 |
-
docker build -t jupyterlab_modelscope .
|
| 15 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: 20250801test
|
| 3 |
+
emoji: 💻🐳
|
| 4 |
+
colorFrom: gray
|
| 5 |
+
colorTo: green
|
| 6 |
+
sdk: docker
|
| 7 |
+
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- jupyterlab
|
| 10 |
+
suggested_storage: small
|
| 11 |
+
license: apache-2.0
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
docker build -t jupyterlab_modelscope .
|
| 15 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
login.html
CHANGED
|
@@ -1,68 +1,68 @@
|
|
| 1 |
-
{% extends "page.html" %}
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
{% block stylesheet %}
|
| 5 |
-
{% endblock %}
|
| 6 |
-
|
| 7 |
-
{% block site %}
|
| 8 |
-
|
| 9 |
-
<div id="jupyter-main-app" class="container">
|
| 10 |
-
|
| 11 |
-
<img src="https://huggingface.co/front/assets/huggingface_logo-noborder.svg" alt="Hugging Face Logo">
|
| 12 |
-
<h4>Welcome to JupyterLab</h4>
|
| 13 |
-
|
| 14 |
-
<h5>The default token is <span style="color:orange;">huggingface</span></h5>
|
| 15 |
-
|
| 16 |
-
{% if login_available %}
|
| 17 |
-
{# login_available means password-login is allowed. Show the form. #}
|
| 18 |
-
<div class="row">
|
| 19 |
-
<div class="navbar col-sm-8">
|
| 20 |
-
<div class="navbar-inner">
|
| 21 |
-
<div class="container">
|
| 22 |
-
<div class="center-nav">
|
| 23 |
-
<form action="{{base_url}}login?next={{next}}" method="post" class="navbar-form pull-left">
|
| 24 |
-
{{ xsrf_form_html() | safe }}
|
| 25 |
-
{% if token_available %}
|
| 26 |
-
<label for="password_input"><strong>{% trans %}Jupyter token <span title="This is the secret you set up when deploying your JupyterLab space">ⓘ</span> {% endtrans
|
| 27 |
-
%}</strong></label>
|
| 28 |
-
{% else %}
|
| 29 |
-
<label for="password_input"><strong>{% trans %}Jupyter password:{% endtrans %}</strong></label>
|
| 30 |
-
{% endif %}
|
| 31 |
-
<input type="password" name="password" id="password_input" class="form-control">
|
| 32 |
-
<button type="submit" class="btn btn-default" id="login_submit">{% trans %}Log in{% endtrans
|
| 33 |
-
%}</button>
|
| 34 |
-
</form>
|
| 35 |
-
</div>
|
| 36 |
-
</div>
|
| 37 |
-
</div>
|
| 38 |
-
</div>
|
| 39 |
-
</div>
|
| 40 |
-
{% else %}
|
| 41 |
-
<p>{% trans %}No login available, you shouldn't be seeing this page.{% endtrans %}</p>
|
| 42 |
-
{% endif %}
|
| 43 |
-
|
| 44 |
-
<h5>If you don't have the credentials for this Jupyter space, <a target="_blank" href="https://huggingface.co/spaces/SpacesExamples/jupyterlab?duplicate=true">create your own.</a></h5>
|
| 45 |
-
<br>
|
| 46 |
-
|
| 47 |
-
<p>This template was created by <a href="https://twitter.com/camenduru" target="_blank" >camenduru</a> and <a href="https://huggingface.co/nateraw" target="_blank" >nateraw</a>, with contributions of <a href="https://huggingface.co/osanseviero" target="_blank" >osanseviero</a> and <a href="https://huggingface.co/azzr" target="_blank" >azzr</a> </p>
|
| 48 |
-
{% if message %}
|
| 49 |
-
<div class="row">
|
| 50 |
-
{% for key in message %}
|
| 51 |
-
<div class="message {{key}}">
|
| 52 |
-
{{message[key]}}
|
| 53 |
-
</div>
|
| 54 |
-
{% endfor %}
|
| 55 |
-
</div>
|
| 56 |
-
{% endif %}
|
| 57 |
-
{% if token_available %}
|
| 58 |
-
{% block token_message %}
|
| 59 |
-
|
| 60 |
-
{% endblock token_message %}
|
| 61 |
-
{% endif %}
|
| 62 |
-
</div>
|
| 63 |
-
|
| 64 |
-
{% endblock %}
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
{% block script %}
|
| 68 |
{% endblock %}
|
|
|
|
| 1 |
+
{% extends "page.html" %}
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
{% block stylesheet %}
|
| 5 |
+
{% endblock %}
|
| 6 |
+
|
| 7 |
+
{% block site %}
|
| 8 |
+
|
| 9 |
+
<div id="jupyter-main-app" class="container">
|
| 10 |
+
|
| 11 |
+
<img src="https://huggingface.co/front/assets/huggingface_logo-noborder.svg" alt="Hugging Face Logo">
|
| 12 |
+
<h4>Welcome to JupyterLab</h4>
|
| 13 |
+
|
| 14 |
+
<h5>The default token is <span style="color:orange;">huggingface</span></h5>
|
| 15 |
+
|
| 16 |
+
{% if login_available %}
|
| 17 |
+
{# login_available means password-login is allowed. Show the form. #}
|
| 18 |
+
<div class="row">
|
| 19 |
+
<div class="navbar col-sm-8">
|
| 20 |
+
<div class="navbar-inner">
|
| 21 |
+
<div class="container">
|
| 22 |
+
<div class="center-nav">
|
| 23 |
+
<form action="{{base_url}}login?next={{next}}" method="post" class="navbar-form pull-left">
|
| 24 |
+
{{ xsrf_form_html() | safe }}
|
| 25 |
+
{% if token_available %}
|
| 26 |
+
<label for="password_input"><strong>{% trans %}Jupyter token <span title="This is the secret you set up when deploying your JupyterLab space">ⓘ</span> {% endtrans
|
| 27 |
+
%}</strong></label>
|
| 28 |
+
{% else %}
|
| 29 |
+
<label for="password_input"><strong>{% trans %}Jupyter password:{% endtrans %}</strong></label>
|
| 30 |
+
{% endif %}
|
| 31 |
+
<input type="password" name="password" id="password_input" class="form-control">
|
| 32 |
+
<button type="submit" class="btn btn-default" id="login_submit">{% trans %}Log in{% endtrans
|
| 33 |
+
%}</button>
|
| 34 |
+
</form>
|
| 35 |
+
</div>
|
| 36 |
+
</div>
|
| 37 |
+
</div>
|
| 38 |
+
</div>
|
| 39 |
+
</div>
|
| 40 |
+
{% else %}
|
| 41 |
+
<p>{% trans %}No login available, you shouldn't be seeing this page.{% endtrans %}</p>
|
| 42 |
+
{% endif %}
|
| 43 |
+
|
| 44 |
+
<h5>If you don't have the credentials for this Jupyter space, <a target="_blank" href="https://huggingface.co/spaces/SpacesExamples/jupyterlab?duplicate=true">create your own.</a></h5>
|
| 45 |
+
<br>
|
| 46 |
+
|
| 47 |
+
<p>This template was created by <a href="https://twitter.com/camenduru" target="_blank" >camenduru</a> and <a href="https://huggingface.co/nateraw" target="_blank" >nateraw</a>, with contributions of <a href="https://huggingface.co/osanseviero" target="_blank" >osanseviero</a> and <a href="https://huggingface.co/azzr" target="_blank" >azzr</a> </p>
|
| 48 |
+
{% if message %}
|
| 49 |
+
<div class="row">
|
| 50 |
+
{% for key in message %}
|
| 51 |
+
<div class="message {{key}}">
|
| 52 |
+
{{message[key]}}
|
| 53 |
+
</div>
|
| 54 |
+
{% endfor %}
|
| 55 |
+
</div>
|
| 56 |
+
{% endif %}
|
| 57 |
+
{% if token_available %}
|
| 58 |
+
{% block token_message %}
|
| 59 |
+
|
| 60 |
+
{% endblock token_message %}
|
| 61 |
+
{% endif %}
|
| 62 |
+
</div>
|
| 63 |
+
|
| 64 |
+
{% endblock %}
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
{% block script %}
|
| 68 |
{% endblock %}
|
on_startup.sh
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
-
#!/bin/bash
|
| 2 |
-
# Write some commands here that will run on root user before startup.
|
| 3 |
-
# For example, to clone transformers and install it in dev mode:
|
| 4 |
-
# git clone https://github.com/huggingface/transformers.git
|
| 5 |
# cd transformers && pip install -e ".[dev]"
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Write some commands here that will run on root user before startup.
|
| 3 |
+
# For example, to clone transformers and install it in dev mode:
|
| 4 |
+
# git clone https://github.com/huggingface/transformers.git
|
| 5 |
# cd transformers && pip install -e ".[dev]"
|
pdftranslate_web/pdftranslate-mcp-server/config.ini
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
-
[common]
|
| 2 |
-
cos_region = ap-nanjing
|
| 3 |
-
cos_secret_id = AKID0036B78yiS5NSM3WyIQKzSI1VjgO9qPl
|
| 4 |
-
cos_secret_key = IZhavCLI6IH1WlofM6i9NXUFqGTUOFvS
|
| 5 |
cos_bucket =tts-1258720957
|
|
|
|
| 1 |
+
[common]
|
| 2 |
+
cos_region = ap-nanjing
|
| 3 |
+
cos_secret_id = AKID0036B78yiS5NSM3WyIQKzSI1VjgO9qPl
|
| 4 |
+
cos_secret_key = IZhavCLI6IH1WlofM6i9NXUFqGTUOFvS
|
| 5 |
cos_bucket =tts-1258720957
|
pdftranslate_web/pyproject.toml
CHANGED
|
@@ -1,174 +1,174 @@
|
|
| 1 |
-
[project]
|
| 2 |
-
name = "pdftranslate_web"
|
| 3 |
-
version = "0.0.1"
|
| 4 |
-
description = "用户上传PDF,系统会把它翻译成其他国家语言,保持文档结构不变"
|
| 5 |
-
license = "AGPL-3.0"
|
| 6 |
-
readme = "README.md"
|
| 7 |
-
requires-python = ">=3.10,<3.14"
|
| 8 |
-
authors = [
|
| 9 |
-
{ name = "wwwzhouhui", email = "75271002@qq.com" }
|
| 10 |
-
]
|
| 11 |
-
maintainers = [
|
| 12 |
-
{ name = "wwwzhouhui", email = "75271002@qq.com" }
|
| 13 |
-
]
|
| 14 |
-
classifiers = [
|
| 15 |
-
"Programming Language :: Python :: 3",
|
| 16 |
-
"Operating System :: OS Independent",
|
| 17 |
-
]
|
| 18 |
-
keywords = ["PDF"]
|
| 19 |
-
dependencies = [
|
| 20 |
-
# Core BabelDOC translation engine
|
| 21 |
-
"babeldoc @ git+https://github.com/funstory-ai/BabelDOC.git",
|
| 22 |
-
|
| 23 |
-
# Additional dependencies for web interface
|
| 24 |
-
"httpx[socks]>=0.27.0", # HTTP client for API calls
|
| 25 |
-
"fastapi>=0.116.1", # Web framework
|
| 26 |
-
"uvicorn[standard]>=0.35.0", # ASGI server
|
| 27 |
-
"python-multipart>=0.0.20", # File upload support
|
| 28 |
-
"gradio>=5.34.1", # Web interface
|
| 29 |
-
"requests>=2.32.4", # HTTP client for gradio
|
| 30 |
-
"Pillow>=11.3.0", # Image processing for previews
|
| 31 |
-
]
|
| 32 |
-
|
| 33 |
-
[project.optional-dependencies]
|
| 34 |
-
directml = ["onnxruntime-directml>=1.16.1"]
|
| 35 |
-
cuda = ["onnxruntime-gpu>=1.16.1"]
|
| 36 |
-
memray = ["memray>=1.17.1"]
|
| 37 |
-
|
| 38 |
-
[project.urls]
|
| 39 |
-
Homepage = "https://github.com/wwwzhouhui/pdftranslate_web"
|
| 40 |
-
Issues = "https://github.com/wwwzhouhui/pdftranslate_web/issues"
|
| 41 |
-
|
| 42 |
-
[project.scripts]
|
| 43 |
-
pdftranslate = "pdftranslate_web.api_server:main"
|
| 44 |
-
|
| 45 |
-
[build-system]
|
| 46 |
-
requires = ["hatchling"]
|
| 47 |
-
build-backend = "hatchling.build"
|
| 48 |
-
|
| 49 |
-
[tool.hatch.metadata]
|
| 50 |
-
allow-direct-references = true
|
| 51 |
-
|
| 52 |
-
[tool.hatch.build.targets.wheel]
|
| 53 |
-
packages = ["src/pdftranslate_web"]
|
| 54 |
-
|
| 55 |
-
[tool.flake8]
|
| 56 |
-
ignore = ["E203", "E261", "E501", "W503", "E741", "E501"]
|
| 57 |
-
max-line-length = 88
|
| 58 |
-
|
| 59 |
-
[tool.ruff]
|
| 60 |
-
src = ["babeldoc"]
|
| 61 |
-
target-version = "py310"
|
| 62 |
-
show-fixes = true
|
| 63 |
-
|
| 64 |
-
[tool.ruff.format]
|
| 65 |
-
# Enable reformatting of code snippets in docstrings.
|
| 66 |
-
docstring-code-format = true
|
| 67 |
-
|
| 68 |
-
[tool.ruff.lint]
|
| 69 |
-
ignore = [
|
| 70 |
-
"E203", # 冒号前的空格
|
| 71 |
-
"E261", # 注释前至少两个空格
|
| 72 |
-
"E501", # 行太长
|
| 73 |
-
"E741", # 变量名歧义
|
| 74 |
-
"F841", # 未使用的变量
|
| 75 |
-
"C901", # 太复杂的函数
|
| 76 |
-
"S101", # use assert
|
| 77 |
-
"SIM", # flake8-simplify
|
| 78 |
-
"ARG002", # unused argument
|
| 79 |
-
"S110", # `try`-`except`-`pass` detected, consider logging the exception
|
| 80 |
-
"B024", # abstract class without abstract methods
|
| 81 |
-
"S112", # `try`-`except`-`continue` detected, consider logging the exception
|
| 82 |
-
"COM812", # missing-trailing-comma
|
| 83 |
-
|
| 84 |
-
]
|
| 85 |
-
select = [
|
| 86 |
-
"E", # pycodestyle 错误
|
| 87 |
-
"F", # Pyflakes
|
| 88 |
-
"N", # PEP8 命名
|
| 89 |
-
"B", # flake8-bugbear
|
| 90 |
-
"I", # isort
|
| 91 |
-
"C", # mccabe
|
| 92 |
-
"UP", # pyupgrade
|
| 93 |
-
"S", # flake8-bandit
|
| 94 |
-
"A", # flake8-builtins
|
| 95 |
-
"COM", # flake8-commas
|
| 96 |
-
"ARG", # flake8-unused-arguments
|
| 97 |
-
"PTH", # 使用 pathlib
|
| 98 |
-
]
|
| 99 |
-
|
| 100 |
-
[tool.ruff.lint.flake8-quotes]
|
| 101 |
-
docstring-quotes = "double"
|
| 102 |
-
|
| 103 |
-
[tool.ruff.lint.flake8-annotations]
|
| 104 |
-
suppress-none-returning = true
|
| 105 |
-
|
| 106 |
-
[tool.ruff.lint.isort]
|
| 107 |
-
force-single-line = true
|
| 108 |
-
|
| 109 |
-
[tool.ruff.lint.pydocstyle]
|
| 110 |
-
convention = "google"
|
| 111 |
-
|
| 112 |
-
# 设置一些规则的特定配置
|
| 113 |
-
[tool.ruff.lint.mccabe]
|
| 114 |
-
max-complexity = 10 # 函数圈复杂度阈值
|
| 115 |
-
|
| 116 |
-
[tool.ruff.lint.per-file-ignores]
|
| 117 |
-
"babeldoc/babeldoc_exception/BabelDOCException.py" = ["N999"]
|
| 118 |
-
"babeldoc/format/pdf/pdfinterp.py" = ["N"] # 忽略命名规范
|
| 119 |
-
"tests/*" = ["S101"] # 在测试文件中允许 assert
|
| 120 |
-
"**/__init__.py" = ["F401"] # 允许未使用的导入
|
| 121 |
-
# 忽略 S311 警告,因为这是有意的
|
| 122 |
-
"babeldoc/format/pdf/document_il/midend/paragraph_finder.py" = ["S311"]
|
| 123 |
-
"docs/*" = ["A001"]
|
| 124 |
-
"babeldoc/pdfminer/*" =["A","F", "I", "N", "S", "B", "C", "COM", "ARG", "PTH", "UP"]
|
| 125 |
-
[dependency-groups]
|
| 126 |
-
dev = [
|
| 127 |
-
"bumpver>=2024.1130",
|
| 128 |
-
"markdown-callouts>=0.4.0",
|
| 129 |
-
"markdown-include>=0.8.1",
|
| 130 |
-
"mkdocs-git-authors-plugin>=0.9.2",
|
| 131 |
-
"mkdocs-git-committers-plugin-2>=2.5.0",
|
| 132 |
-
"mkdocs-git-revision-date-localized-plugin>=1.3.0",
|
| 133 |
-
"mkdocs-material[recommended]>=9.6.4",
|
| 134 |
-
"pre-commit>=4.1.0",
|
| 135 |
-
"pygments>=2.19.1",
|
| 136 |
-
"ruff>=0.9.2",
|
| 137 |
-
"pytest>=8.3.4",
|
| 138 |
-
"pylance>=0.29.0",
|
| 139 |
-
"py-spy>=0.4.0",
|
| 140 |
-
]
|
| 141 |
-
|
| 142 |
-
[tool.pytest.ini_options]
|
| 143 |
-
pythonpath = [".", "src"]
|
| 144 |
-
testpaths = ["tests"]
|
| 145 |
-
|
| 146 |
-
[bumpver]
|
| 147 |
-
current_version = "0.0.1"
|
| 148 |
-
version_pattern = "MAJOR.MINOR.PATCH[.PYTAGNUM]"
|
| 149 |
-
|
| 150 |
-
[bumpver.file_patterns]
|
| 151 |
-
"pyproject.toml" = [
|
| 152 |
-
'current_version = "{version}"',
|
| 153 |
-
'version = "{version}"'
|
| 154 |
-
]
|
| 155 |
-
"babeldoc/__init__.py" = [
|
| 156 |
-
'__version__ = "{version}"'
|
| 157 |
-
]
|
| 158 |
-
"babeldoc/main.py" = [
|
| 159 |
-
'__version__ = "{version}"'
|
| 160 |
-
]
|
| 161 |
-
"babeldoc/const.py" = [
|
| 162 |
-
'__version__ = "{version}"'
|
| 163 |
-
]
|
| 164 |
-
|
| 165 |
-
[tool.uv.sources]
|
| 166 |
-
yadt = { path = ".", editable = true }
|
| 167 |
-
|
| 168 |
-
[tool.pyright]
|
| 169 |
-
pythonVersion = "3.10"
|
| 170 |
-
# typeCheckingMode = "off"
|
| 171 |
-
reportGeneralTypeIssues = false
|
| 172 |
-
reportUnknownVariableType = false
|
| 173 |
-
reportMissingParameterType = false
|
| 174 |
-
reportUnknownParameterType = false
|
|
|
|
| 1 |
+
[project]
|
| 2 |
+
name = "pdftranslate_web"
|
| 3 |
+
version = "0.0.1"
|
| 4 |
+
description = "用户上传PDF,系统会把它翻译成其他国家语言,保持文档结构不变"
|
| 5 |
+
license = "AGPL-3.0"
|
| 6 |
+
readme = "README.md"
|
| 7 |
+
requires-python = ">=3.10,<3.14"
|
| 8 |
+
authors = [
|
| 9 |
+
{ name = "wwwzhouhui", email = "75271002@qq.com" }
|
| 10 |
+
]
|
| 11 |
+
maintainers = [
|
| 12 |
+
{ name = "wwwzhouhui", email = "75271002@qq.com" }
|
| 13 |
+
]
|
| 14 |
+
classifiers = [
|
| 15 |
+
"Programming Language :: Python :: 3",
|
| 16 |
+
"Operating System :: OS Independent",
|
| 17 |
+
]
|
| 18 |
+
keywords = ["PDF"]
|
| 19 |
+
dependencies = [
|
| 20 |
+
# Core BabelDOC translation engine
|
| 21 |
+
"babeldoc @ git+https://github.com/funstory-ai/BabelDOC.git",
|
| 22 |
+
|
| 23 |
+
# Additional dependencies for web interface
|
| 24 |
+
"httpx[socks]>=0.27.0", # HTTP client for API calls
|
| 25 |
+
"fastapi>=0.116.1", # Web framework
|
| 26 |
+
"uvicorn[standard]>=0.35.0", # ASGI server
|
| 27 |
+
"python-multipart>=0.0.20", # File upload support
|
| 28 |
+
"gradio>=5.34.1", # Web interface
|
| 29 |
+
"requests>=2.32.4", # HTTP client for gradio
|
| 30 |
+
"Pillow>=11.3.0", # Image processing for previews
|
| 31 |
+
]
|
| 32 |
+
|
| 33 |
+
[project.optional-dependencies]
|
| 34 |
+
directml = ["onnxruntime-directml>=1.16.1"]
|
| 35 |
+
cuda = ["onnxruntime-gpu>=1.16.1"]
|
| 36 |
+
memray = ["memray>=1.17.1"]
|
| 37 |
+
|
| 38 |
+
[project.urls]
|
| 39 |
+
Homepage = "https://github.com/wwwzhouhui/pdftranslate_web"
|
| 40 |
+
Issues = "https://github.com/wwwzhouhui/pdftranslate_web/issues"
|
| 41 |
+
|
| 42 |
+
[project.scripts]
|
| 43 |
+
pdftranslate = "pdftranslate_web.api_server:main"
|
| 44 |
+
|
| 45 |
+
[build-system]
|
| 46 |
+
requires = ["hatchling"]
|
| 47 |
+
build-backend = "hatchling.build"
|
| 48 |
+
|
| 49 |
+
[tool.hatch.metadata]
|
| 50 |
+
allow-direct-references = true
|
| 51 |
+
|
| 52 |
+
[tool.hatch.build.targets.wheel]
|
| 53 |
+
packages = ["src/pdftranslate_web"]
|
| 54 |
+
|
| 55 |
+
[tool.flake8]
|
| 56 |
+
ignore = ["E203", "E261", "E501", "W503", "E741", "E501"]
|
| 57 |
+
max-line-length = 88
|
| 58 |
+
|
| 59 |
+
[tool.ruff]
|
| 60 |
+
src = ["babeldoc"]
|
| 61 |
+
target-version = "py310"
|
| 62 |
+
show-fixes = true
|
| 63 |
+
|
| 64 |
+
[tool.ruff.format]
|
| 65 |
+
# Enable reformatting of code snippets in docstrings.
|
| 66 |
+
docstring-code-format = true
|
| 67 |
+
|
| 68 |
+
[tool.ruff.lint]
|
| 69 |
+
ignore = [
|
| 70 |
+
"E203", # 冒号前的空格
|
| 71 |
+
"E261", # 注释前至少两个空格
|
| 72 |
+
"E501", # 行太长
|
| 73 |
+
"E741", # 变量名歧义
|
| 74 |
+
"F841", # 未使用的变量
|
| 75 |
+
"C901", # 太复杂的函数
|
| 76 |
+
"S101", # use assert
|
| 77 |
+
"SIM", # flake8-simplify
|
| 78 |
+
"ARG002", # unused argument
|
| 79 |
+
"S110", # `try`-`except`-`pass` detected, consider logging the exception
|
| 80 |
+
"B024", # abstract class without abstract methods
|
| 81 |
+
"S112", # `try`-`except`-`continue` detected, consider logging the exception
|
| 82 |
+
"COM812", # missing-trailing-comma
|
| 83 |
+
|
| 84 |
+
]
|
| 85 |
+
select = [
|
| 86 |
+
"E", # pycodestyle 错误
|
| 87 |
+
"F", # Pyflakes
|
| 88 |
+
"N", # PEP8 命名
|
| 89 |
+
"B", # flake8-bugbear
|
| 90 |
+
"I", # isort
|
| 91 |
+
"C", # mccabe
|
| 92 |
+
"UP", # pyupgrade
|
| 93 |
+
"S", # flake8-bandit
|
| 94 |
+
"A", # flake8-builtins
|
| 95 |
+
"COM", # flake8-commas
|
| 96 |
+
"ARG", # flake8-unused-arguments
|
| 97 |
+
"PTH", # 使用 pathlib
|
| 98 |
+
]
|
| 99 |
+
|
| 100 |
+
[tool.ruff.lint.flake8-quotes]
|
| 101 |
+
docstring-quotes = "double"
|
| 102 |
+
|
| 103 |
+
[tool.ruff.lint.flake8-annotations]
|
| 104 |
+
suppress-none-returning = true
|
| 105 |
+
|
| 106 |
+
[tool.ruff.lint.isort]
|
| 107 |
+
force-single-line = true
|
| 108 |
+
|
| 109 |
+
[tool.ruff.lint.pydocstyle]
|
| 110 |
+
convention = "google"
|
| 111 |
+
|
| 112 |
+
# 设置一些规则的特定配置
|
| 113 |
+
[tool.ruff.lint.mccabe]
|
| 114 |
+
max-complexity = 10 # 函数圈复杂度阈值
|
| 115 |
+
|
| 116 |
+
[tool.ruff.lint.per-file-ignores]
|
| 117 |
+
"babeldoc/babeldoc_exception/BabelDOCException.py" = ["N999"]
|
| 118 |
+
"babeldoc/format/pdf/pdfinterp.py" = ["N"] # 忽略命名规范
|
| 119 |
+
"tests/*" = ["S101"] # 在测试文件中允许 assert
|
| 120 |
+
"**/__init__.py" = ["F401"] # 允许未使用的导入
|
| 121 |
+
# 忽略 S311 警告,因为这是有意的
|
| 122 |
+
"babeldoc/format/pdf/document_il/midend/paragraph_finder.py" = ["S311"]
|
| 123 |
+
"docs/*" = ["A001"]
|
| 124 |
+
"babeldoc/pdfminer/*" =["A","F", "I", "N", "S", "B", "C", "COM", "ARG", "PTH", "UP"]
|
| 125 |
+
[dependency-groups]
|
| 126 |
+
dev = [
|
| 127 |
+
"bumpver>=2024.1130",
|
| 128 |
+
"markdown-callouts>=0.4.0",
|
| 129 |
+
"markdown-include>=0.8.1",
|
| 130 |
+
"mkdocs-git-authors-plugin>=0.9.2",
|
| 131 |
+
"mkdocs-git-committers-plugin-2>=2.5.0",
|
| 132 |
+
"mkdocs-git-revision-date-localized-plugin>=1.3.0",
|
| 133 |
+
"mkdocs-material[recommended]>=9.6.4",
|
| 134 |
+
"pre-commit>=4.1.0",
|
| 135 |
+
"pygments>=2.19.1",
|
| 136 |
+
"ruff>=0.9.2",
|
| 137 |
+
"pytest>=8.3.4",
|
| 138 |
+
"pylance>=0.29.0",
|
| 139 |
+
"py-spy>=0.4.0",
|
| 140 |
+
]
|
| 141 |
+
|
| 142 |
+
[tool.pytest.ini_options]
|
| 143 |
+
pythonpath = [".", "src"]
|
| 144 |
+
testpaths = ["tests"]
|
| 145 |
+
|
| 146 |
+
[bumpver]
|
| 147 |
+
current_version = "0.0.1"
|
| 148 |
+
version_pattern = "MAJOR.MINOR.PATCH[.PYTAGNUM]"
|
| 149 |
+
|
| 150 |
+
[bumpver.file_patterns]
|
| 151 |
+
"pyproject.toml" = [
|
| 152 |
+
'current_version = "{version}"',
|
| 153 |
+
'version = "{version}"'
|
| 154 |
+
]
|
| 155 |
+
"babeldoc/__init__.py" = [
|
| 156 |
+
'__version__ = "{version}"'
|
| 157 |
+
]
|
| 158 |
+
"babeldoc/main.py" = [
|
| 159 |
+
'__version__ = "{version}"'
|
| 160 |
+
]
|
| 161 |
+
"babeldoc/const.py" = [
|
| 162 |
+
'__version__ = "{version}"'
|
| 163 |
+
]
|
| 164 |
+
|
| 165 |
+
[tool.uv.sources]
|
| 166 |
+
yadt = { path = ".", editable = true }
|
| 167 |
+
|
| 168 |
+
[tool.pyright]
|
| 169 |
+
pythonVersion = "3.10"
|
| 170 |
+
# typeCheckingMode = "off"
|
| 171 |
+
reportGeneralTypeIssues = false
|
| 172 |
+
reportUnknownVariableType = false
|
| 173 |
+
reportMissingParameterType = false
|
| 174 |
+
reportUnknownParameterType = false
|
pdftranslate_web/pyproject_scnet.toml
CHANGED
|
@@ -1,176 +1,176 @@
|
|
| 1 |
-
[project]
|
| 2 |
-
name = "pdftranslate_web"
|
| 3 |
-
version = "0.0.1"
|
| 4 |
-
description = "用户上传PDF,系统会把它翻译成其他国家语言,保持文档结构不变"
|
| 5 |
-
license = "AGPL-3.0"
|
| 6 |
-
readme = "README.md"
|
| 7 |
-
requires-python = ">=3.10,<3.14"
|
| 8 |
-
authors = [
|
| 9 |
-
{ name = "wwwzhouhui", email = "75271002@qq.com" }
|
| 10 |
-
]
|
| 11 |
-
maintainers = [
|
| 12 |
-
{ name = "wwwzhouhui", email = "75271002@qq.com" }
|
| 13 |
-
]
|
| 14 |
-
classifiers = [
|
| 15 |
-
"Programming Language :: Python :: 3",
|
| 16 |
-
"Operating System :: OS Independent",
|
| 17 |
-
]
|
| 18 |
-
keywords = ["PDF"]
|
| 19 |
-
dependencies = [
|
| 20 |
-
# Core BabelDOC translation engine
|
| 21 |
-
"babeldoc @ git+https://ghfast.top//https://github.com/funstory-ai/BabelDOC.git",
|
| 22 |
-
|
| 23 |
-
"onnxruntime<1.17.0",
|
| 24 |
-
# Additional dependencies for web interface
|
| 25 |
-
"httpx[socks]>=0.27.0", # HTTP client for API calls
|
| 26 |
-
"fastapi>=0.116.1", # Web framework
|
| 27 |
-
"uvicorn[standard]>=0.35.0", # ASGI server
|
| 28 |
-
"python-multipart>=0.0.20", # File upload support
|
| 29 |
-
"gradio>=5.34.1", # Web interface
|
| 30 |
-
"requests>=2.32.4", # HTTP client for gradio
|
| 31 |
-
"Pillow>=11.3.0", # Image processing for previews
|
| 32 |
-
]
|
| 33 |
-
|
| 34 |
-
[project.optional-dependencies]
|
| 35 |
-
directml = ["onnxruntime-directml==1.15.1"]
|
| 36 |
-
cuda = ["onnxruntime-gpu==1.15.1"]
|
| 37 |
-
memray = ["memray>=1.17.1"]
|
| 38 |
-
|
| 39 |
-
[project.urls]
|
| 40 |
-
Homepage = "https://github.com/wwwzhouhui/pdftranslate_web"
|
| 41 |
-
Issues = "https://github.com/wwwzhouhui/pdftranslate_web/issues"
|
| 42 |
-
|
| 43 |
-
[project.scripts]
|
| 44 |
-
pdftranslate = "pdftranslate_web.api_server:main"
|
| 45 |
-
|
| 46 |
-
[build-system]
|
| 47 |
-
requires = ["hatchling"]
|
| 48 |
-
build-backend = "hatchling.build"
|
| 49 |
-
|
| 50 |
-
[tool.hatch.metadata]
|
| 51 |
-
allow-direct-references = true
|
| 52 |
-
|
| 53 |
-
[tool.hatch.build.targets.wheel]
|
| 54 |
-
packages = ["src/pdftranslate_web"]
|
| 55 |
-
|
| 56 |
-
[tool.flake8]
|
| 57 |
-
ignore = ["E203", "E261", "E501", "W503", "E741", "E501"]
|
| 58 |
-
max-line-length = 88
|
| 59 |
-
|
| 60 |
-
[tool.ruff]
|
| 61 |
-
src = ["babeldoc"]
|
| 62 |
-
target-version = "py310"
|
| 63 |
-
show-fixes = true
|
| 64 |
-
|
| 65 |
-
[tool.ruff.format]
|
| 66 |
-
# Enable reformatting of code snippets in docstrings.
|
| 67 |
-
docstring-code-format = true
|
| 68 |
-
|
| 69 |
-
[tool.ruff.lint]
|
| 70 |
-
ignore = [
|
| 71 |
-
"E203", # 冒号前的空格
|
| 72 |
-
"E261", # 注释前至少两个空格
|
| 73 |
-
"E501", # 行太长
|
| 74 |
-
"E741", # 变量名歧义
|
| 75 |
-
"F841", # 未使用的变量
|
| 76 |
-
"C901", # 太复杂的函数
|
| 77 |
-
"S101", # use assert
|
| 78 |
-
"SIM", # flake8-simplify
|
| 79 |
-
"ARG002", # unused argument
|
| 80 |
-
"S110", # `try`-`except`-`pass` detected, consider logging the exception
|
| 81 |
-
"B024", # abstract class without abstract methods
|
| 82 |
-
"S112", # `try`-`except`-`continue` detected, consider logging the exception
|
| 83 |
-
"COM812", # missing-trailing-comma
|
| 84 |
-
|
| 85 |
-
]
|
| 86 |
-
select = [
|
| 87 |
-
"E", # pycodestyle 错误
|
| 88 |
-
"F", # Pyflakes
|
| 89 |
-
"N", # PEP8 命名
|
| 90 |
-
"B", # flake8-bugbear
|
| 91 |
-
"I", # isort
|
| 92 |
-
"C", # mccabe
|
| 93 |
-
"UP", # pyupgrade
|
| 94 |
-
"S", # flake8-bandit
|
| 95 |
-
"A", # flake8-builtins
|
| 96 |
-
"COM", # flake8-commas
|
| 97 |
-
"ARG", # flake8-unused-arguments
|
| 98 |
-
"PTH", # 使用 pathlib
|
| 99 |
-
]
|
| 100 |
-
|
| 101 |
-
[tool.ruff.lint.flake8-quotes]
|
| 102 |
-
docstring-quotes = "double"
|
| 103 |
-
|
| 104 |
-
[tool.ruff.lint.flake8-annotations]
|
| 105 |
-
suppress-none-returning = true
|
| 106 |
-
|
| 107 |
-
[tool.ruff.lint.isort]
|
| 108 |
-
force-single-line = true
|
| 109 |
-
|
| 110 |
-
[tool.ruff.lint.pydocstyle]
|
| 111 |
-
convention = "google"
|
| 112 |
-
|
| 113 |
-
# 设置一些规则的特定配置
|
| 114 |
-
[tool.ruff.lint.mccabe]
|
| 115 |
-
max-complexity = 10 # 函数圈复杂度阈值
|
| 116 |
-
|
| 117 |
-
[tool.ruff.lint.per-file-ignores]
|
| 118 |
-
"babeldoc/babeldoc_exception/BabelDOCException.py" = ["N999"]
|
| 119 |
-
"babeldoc/format/pdf/pdfinterp.py" = ["N"] # 忽略命名规范
|
| 120 |
-
"tests/*" = ["S101"] # 在测试文件中允许 assert
|
| 121 |
-
"**/__init__.py" = ["F401"] # 允许未使用的导入
|
| 122 |
-
# 忽略 S311 警告,因为这是有意的
|
| 123 |
-
"babeldoc/format/pdf/document_il/midend/paragraph_finder.py" = ["S311"]
|
| 124 |
-
"docs/*" = ["A001"]
|
| 125 |
-
"babeldoc/pdfminer/*" =["A","F", "I", "N", "S", "B", "C", "COM", "ARG", "PTH", "UP"]
|
| 126 |
-
[dependency-groups]
|
| 127 |
-
dev = [
|
| 128 |
-
"bumpver>=2024.1130",
|
| 129 |
-
"markdown-callouts>=0.4.0",
|
| 130 |
-
"markdown-include>=0.8.1",
|
| 131 |
-
"mkdocs-git-authors-plugin>=0.9.2",
|
| 132 |
-
"mkdocs-git-committers-plugin-2>=2.5.0",
|
| 133 |
-
"mkdocs-git-revision-date-localized-plugin>=1.3.0",
|
| 134 |
-
"mkdocs-material[recommended]>=9.6.4",
|
| 135 |
-
"pre-commit>=4.1.0",
|
| 136 |
-
"pygments>=2.19.1",
|
| 137 |
-
"ruff>=0.9.2",
|
| 138 |
-
"pytest>=8.3.4",
|
| 139 |
-
"pylance>=0.29.0",
|
| 140 |
-
"py-spy>=0.4.0",
|
| 141 |
-
]
|
| 142 |
-
|
| 143 |
-
[tool.pytest.ini_options]
|
| 144 |
-
pythonpath = [".", "src"]
|
| 145 |
-
testpaths = ["tests"]
|
| 146 |
-
|
| 147 |
-
[bumpver]
|
| 148 |
-
current_version = "0.0.1"
|
| 149 |
-
version_pattern = "MAJOR.MINOR.PATCH[.PYTAGNUM]"
|
| 150 |
-
|
| 151 |
-
[bumpver.file_patterns]
|
| 152 |
-
"pyproject.toml" = [
|
| 153 |
-
'current_version = "{version}"',
|
| 154 |
-
'version = "{version}"'
|
| 155 |
-
]
|
| 156 |
-
"babeldoc/__init__.py" = [
|
| 157 |
-
'__version__ = "{version}"'
|
| 158 |
-
]
|
| 159 |
-
"babeldoc/main.py" = [
|
| 160 |
-
'__version__ = "{version}"'
|
| 161 |
-
]
|
| 162 |
-
"babeldoc/const.py" = [
|
| 163 |
-
'__version__ = "{version}"'
|
| 164 |
-
]
|
| 165 |
-
|
| 166 |
-
[tool.uv.sources]
|
| 167 |
-
yadt = { path = ".", editable = true }
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
[tool.pyright]
|
| 171 |
-
pythonVersion = "3.10"
|
| 172 |
-
# typeCheckingMode = "off"
|
| 173 |
-
reportGeneralTypeIssues = false
|
| 174 |
-
reportUnknownVariableType = false
|
| 175 |
-
reportMissingParameterType = false
|
| 176 |
-
reportUnknownParameterType = false
|
|
|
|
| 1 |
+
[project]
|
| 2 |
+
name = "pdftranslate_web"
|
| 3 |
+
version = "0.0.1"
|
| 4 |
+
description = "用户上传PDF,系统会把它翻译成其他国家语言,保持文档结构不变"
|
| 5 |
+
license = "AGPL-3.0"
|
| 6 |
+
readme = "README.md"
|
| 7 |
+
requires-python = ">=3.10,<3.14"
|
| 8 |
+
authors = [
|
| 9 |
+
{ name = "wwwzhouhui", email = "75271002@qq.com" }
|
| 10 |
+
]
|
| 11 |
+
maintainers = [
|
| 12 |
+
{ name = "wwwzhouhui", email = "75271002@qq.com" }
|
| 13 |
+
]
|
| 14 |
+
classifiers = [
|
| 15 |
+
"Programming Language :: Python :: 3",
|
| 16 |
+
"Operating System :: OS Independent",
|
| 17 |
+
]
|
| 18 |
+
keywords = ["PDF"]
|
| 19 |
+
dependencies = [
|
| 20 |
+
# Core BabelDOC translation engine
|
| 21 |
+
"babeldoc @ git+https://ghfast.top//https://github.com/funstory-ai/BabelDOC.git",
|
| 22 |
+
|
| 23 |
+
"onnxruntime<1.17.0",
|
| 24 |
+
# Additional dependencies for web interface
|
| 25 |
+
"httpx[socks]>=0.27.0", # HTTP client for API calls
|
| 26 |
+
"fastapi>=0.116.1", # Web framework
|
| 27 |
+
"uvicorn[standard]>=0.35.0", # ASGI server
|
| 28 |
+
"python-multipart>=0.0.20", # File upload support
|
| 29 |
+
"gradio>=5.34.1", # Web interface
|
| 30 |
+
"requests>=2.32.4", # HTTP client for gradio
|
| 31 |
+
"Pillow>=11.3.0", # Image processing for previews
|
| 32 |
+
]
|
| 33 |
+
|
| 34 |
+
[project.optional-dependencies]
|
| 35 |
+
directml = ["onnxruntime-directml==1.15.1"]
|
| 36 |
+
cuda = ["onnxruntime-gpu==1.15.1"]
|
| 37 |
+
memray = ["memray>=1.17.1"]
|
| 38 |
+
|
| 39 |
+
[project.urls]
|
| 40 |
+
Homepage = "https://github.com/wwwzhouhui/pdftranslate_web"
|
| 41 |
+
Issues = "https://github.com/wwwzhouhui/pdftranslate_web/issues"
|
| 42 |
+
|
| 43 |
+
[project.scripts]
|
| 44 |
+
pdftranslate = "pdftranslate_web.api_server:main"
|
| 45 |
+
|
| 46 |
+
[build-system]
|
| 47 |
+
requires = ["hatchling"]
|
| 48 |
+
build-backend = "hatchling.build"
|
| 49 |
+
|
| 50 |
+
[tool.hatch.metadata]
|
| 51 |
+
allow-direct-references = true
|
| 52 |
+
|
| 53 |
+
[tool.hatch.build.targets.wheel]
|
| 54 |
+
packages = ["src/pdftranslate_web"]
|
| 55 |
+
|
| 56 |
+
[tool.flake8]
|
| 57 |
+
ignore = ["E203", "E261", "E501", "W503", "E741", "E501"]
|
| 58 |
+
max-line-length = 88
|
| 59 |
+
|
| 60 |
+
[tool.ruff]
|
| 61 |
+
src = ["babeldoc"]
|
| 62 |
+
target-version = "py310"
|
| 63 |
+
show-fixes = true
|
| 64 |
+
|
| 65 |
+
[tool.ruff.format]
|
| 66 |
+
# Enable reformatting of code snippets in docstrings.
|
| 67 |
+
docstring-code-format = true
|
| 68 |
+
|
| 69 |
+
[tool.ruff.lint]
|
| 70 |
+
ignore = [
|
| 71 |
+
"E203", # 冒号前的空格
|
| 72 |
+
"E261", # 注释前至少两个空格
|
| 73 |
+
"E501", # 行太长
|
| 74 |
+
"E741", # 变量名歧义
|
| 75 |
+
"F841", # 未使用的变量
|
| 76 |
+
"C901", # 太复杂的函数
|
| 77 |
+
"S101", # use assert
|
| 78 |
+
"SIM", # flake8-simplify
|
| 79 |
+
"ARG002", # unused argument
|
| 80 |
+
"S110", # `try`-`except`-`pass` detected, consider logging the exception
|
| 81 |
+
"B024", # abstract class without abstract methods
|
| 82 |
+
"S112", # `try`-`except`-`continue` detected, consider logging the exception
|
| 83 |
+
"COM812", # missing-trailing-comma
|
| 84 |
+
|
| 85 |
+
]
|
| 86 |
+
select = [
|
| 87 |
+
"E", # pycodestyle 错误
|
| 88 |
+
"F", # Pyflakes
|
| 89 |
+
"N", # PEP8 命名
|
| 90 |
+
"B", # flake8-bugbear
|
| 91 |
+
"I", # isort
|
| 92 |
+
"C", # mccabe
|
| 93 |
+
"UP", # pyupgrade
|
| 94 |
+
"S", # flake8-bandit
|
| 95 |
+
"A", # flake8-builtins
|
| 96 |
+
"COM", # flake8-commas
|
| 97 |
+
"ARG", # flake8-unused-arguments
|
| 98 |
+
"PTH", # 使用 pathlib
|
| 99 |
+
]
|
| 100 |
+
|
| 101 |
+
[tool.ruff.lint.flake8-quotes]
|
| 102 |
+
docstring-quotes = "double"
|
| 103 |
+
|
| 104 |
+
[tool.ruff.lint.flake8-annotations]
|
| 105 |
+
suppress-none-returning = true
|
| 106 |
+
|
| 107 |
+
[tool.ruff.lint.isort]
|
| 108 |
+
force-single-line = true
|
| 109 |
+
|
| 110 |
+
[tool.ruff.lint.pydocstyle]
|
| 111 |
+
convention = "google"
|
| 112 |
+
|
| 113 |
+
# 设置一些规则的特定配置
|
| 114 |
+
[tool.ruff.lint.mccabe]
|
| 115 |
+
max-complexity = 10 # 函数圈复杂度阈值
|
| 116 |
+
|
| 117 |
+
[tool.ruff.lint.per-file-ignores]
|
| 118 |
+
"babeldoc/babeldoc_exception/BabelDOCException.py" = ["N999"]
|
| 119 |
+
"babeldoc/format/pdf/pdfinterp.py" = ["N"] # 忽略命名规范
|
| 120 |
+
"tests/*" = ["S101"] # 在测试文件中允许 assert
|
| 121 |
+
"**/__init__.py" = ["F401"] # 允许未使用的导入
|
| 122 |
+
# 忽略 S311 警告,因为这是有意的
|
| 123 |
+
"babeldoc/format/pdf/document_il/midend/paragraph_finder.py" = ["S311"]
|
| 124 |
+
"docs/*" = ["A001"]
|
| 125 |
+
"babeldoc/pdfminer/*" =["A","F", "I", "N", "S", "B", "C", "COM", "ARG", "PTH", "UP"]
|
| 126 |
+
[dependency-groups]
|
| 127 |
+
dev = [
|
| 128 |
+
"bumpver>=2024.1130",
|
| 129 |
+
"markdown-callouts>=0.4.0",
|
| 130 |
+
"markdown-include>=0.8.1",
|
| 131 |
+
"mkdocs-git-authors-plugin>=0.9.2",
|
| 132 |
+
"mkdocs-git-committers-plugin-2>=2.5.0",
|
| 133 |
+
"mkdocs-git-revision-date-localized-plugin>=1.3.0",
|
| 134 |
+
"mkdocs-material[recommended]>=9.6.4",
|
| 135 |
+
"pre-commit>=4.1.0",
|
| 136 |
+
"pygments>=2.19.1",
|
| 137 |
+
"ruff>=0.9.2",
|
| 138 |
+
"pytest>=8.3.4",
|
| 139 |
+
"pylance>=0.29.0",
|
| 140 |
+
"py-spy>=0.4.0",
|
| 141 |
+
]
|
| 142 |
+
|
| 143 |
+
[tool.pytest.ini_options]
|
| 144 |
+
pythonpath = [".", "src"]
|
| 145 |
+
testpaths = ["tests"]
|
| 146 |
+
|
| 147 |
+
[bumpver]
|
| 148 |
+
current_version = "0.0.1"
|
| 149 |
+
version_pattern = "MAJOR.MINOR.PATCH[.PYTAGNUM]"
|
| 150 |
+
|
| 151 |
+
[bumpver.file_patterns]
|
| 152 |
+
"pyproject.toml" = [
|
| 153 |
+
'current_version = "{version}"',
|
| 154 |
+
'version = "{version}"'
|
| 155 |
+
]
|
| 156 |
+
"babeldoc/__init__.py" = [
|
| 157 |
+
'__version__ = "{version}"'
|
| 158 |
+
]
|
| 159 |
+
"babeldoc/main.py" = [
|
| 160 |
+
'__version__ = "{version}"'
|
| 161 |
+
]
|
| 162 |
+
"babeldoc/const.py" = [
|
| 163 |
+
'__version__ = "{version}"'
|
| 164 |
+
]
|
| 165 |
+
|
| 166 |
+
[tool.uv.sources]
|
| 167 |
+
yadt = { path = ".", editable = true }
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
[tool.pyright]
|
| 171 |
+
pythonVersion = "3.10"
|
| 172 |
+
# typeCheckingMode = "off"
|
| 173 |
+
reportGeneralTypeIssues = false
|
| 174 |
+
reportUnknownVariableType = false
|
| 175 |
+
reportMissingParameterType = false
|
| 176 |
+
reportUnknownParameterType = false
|
requirements.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
jupyterlab==4.4.5
|
| 2 |
-
tornado==6.2
|
| 3 |
-
ipywidgets
|
| 4 |
uv==0.8.4
|
|
|
|
| 1 |
+
jupyterlab==4.4.5
|
| 2 |
+
tornado==6.2
|
| 3 |
+
ipywidgets
|
| 4 |
uv==0.8.4
|
start_server.sh
CHANGED
|
@@ -1,19 +1,19 @@
|
|
| 1 |
-
#!/bin/bash
|
| 2 |
-
JUPYTER_TOKEN="${JUPYTER_TOKEN:=huggingface}"
|
| 3 |
-
|
| 4 |
-
NOTEBOOK_DIR="/data"
|
| 5 |
-
|
| 6 |
-
jupyter labextension disable "@jupyterlab/apputils-extension:announcements"
|
| 7 |
-
|
| 8 |
-
jupyter-lab \
|
| 9 |
-
--ip 0.0.0.0 \
|
| 10 |
-
--port 7860 \
|
| 11 |
-
--no-browser \
|
| 12 |
-
--allow-root \
|
| 13 |
-
--ServerApp.token="$JUPYTER_TOKEN" \
|
| 14 |
-
--ServerApp.tornado_settings="{'headers': {'Content-Security-Policy': 'frame-ancestors *'}}" \
|
| 15 |
-
--ServerApp.cookie_options="{'SameSite': 'None', 'Secure': True}" \
|
| 16 |
-
--ServerApp.disable_check_xsrf=True \
|
| 17 |
-
--LabApp.news_url=None \
|
| 18 |
-
--LabApp.check_for_updates_class="jupyterlab.NeverCheckForUpdate" \
|
| 19 |
-
--notebook-dir=$NOTEBOOK_DIR
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
JUPYTER_TOKEN="${JUPYTER_TOKEN:=huggingface}"
|
| 3 |
+
|
| 4 |
+
NOTEBOOK_DIR="/data"
|
| 5 |
+
|
| 6 |
+
jupyter labextension disable "@jupyterlab/apputils-extension:announcements"
|
| 7 |
+
|
| 8 |
+
jupyter-lab \
|
| 9 |
+
--ip 0.0.0.0 \
|
| 10 |
+
--port 7860 \
|
| 11 |
+
--no-browser \
|
| 12 |
+
--allow-root \
|
| 13 |
+
--ServerApp.token="$JUPYTER_TOKEN" \
|
| 14 |
+
--ServerApp.tornado_settings="{'headers': {'Content-Security-Policy': 'frame-ancestors *'}}" \
|
| 15 |
+
--ServerApp.cookie_options="{'SameSite': 'None', 'Secure': True}" \
|
| 16 |
+
--ServerApp.disable_check_xsrf=True \
|
| 17 |
+
--LabApp.news_url=None \
|
| 18 |
+
--LabApp.check_for_updates_class="jupyterlab.NeverCheckForUpdate" \
|
| 19 |
+
--notebook-dir=$NOTEBOOK_DIR
|