update plant.md, requirements.txt
This commit is contained in:
51
plant.md
51
plant.md
@@ -9,11 +9,25 @@
|
||||
在一台可联网机器上完成一次完整解析与下载:
|
||||
|
||||
```bash
|
||||
deactivate # 如果当前 shell 里已经激活了 uv 创建的虚拟环境
|
||||
uv sync
|
||||
uv export --frozen --no-dev -o requirements.txt
|
||||
uv pip download -r requirements.txt -d wheelhouse
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y python3-pip build-essential libxml2-dev libxslt1-dev zlib1g-dev python3-dev
|
||||
/usr/bin/python3 -m pip wheel -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt -w wheelhouse
|
||||
```
|
||||
|
||||
不要使用当前 `.venv/bin/python3`,它可能没有 `pip` 模块。`/usr/bin/python3` 必须配合系统包 `python3-pip` 使用。
|
||||
|
||||
如果 `lxml` 仍报 “No matching distribution found”,先强制走官方 PyPI,再单独构建一次:
|
||||
|
||||
```bash
|
||||
/usr/bin/python3 -m pip wheel -i https://pypi.org/simple -r requirements.txt -w wheelhouse
|
||||
/usr/bin/python3 -m pip wheel -i https://pypi.org/simple "lxml==6.1.0" -w wheelhouse
|
||||
```
|
||||
|
||||
这类报错通常是准备机的镜像源不全,或者镜像源没有同步到当前 Python 版本对应的二进制包。
|
||||
|
||||
同时打包以下内容:
|
||||
|
||||
- `app/`
|
||||
@@ -27,7 +41,32 @@ uv pip download -r requirements.txt -d wheelhouse
|
||||
- `wheelhouse/`
|
||||
- `uv` 可执行文件(Linux x86_64)
|
||||
|
||||
如果目标机没有 Python 3.10+,还要额外准备一个可移植的 Python 3.10/3.12 运行时目录。
|
||||
如果目标机没有 Python 3.10+,还要额外准备一个可移植的 Python 3.10/3.12 运行时目录。推荐在准备机上先安装并验证该运行时,再打包整目录,例如:
|
||||
|
||||
```bash
|
||||
sudo /home/zjz/.local/bin/uv python install 3.12 --install-dir /opt/python-3.12
|
||||
find /opt/python-3.12 -path '*/bin/python3.12' -print
|
||||
/opt/python-3.12/cpython-3.12.13-linux-x86_64-gnu/bin/python3.12 --version
|
||||
/opt/python-3.12/cpython-3.12.13-linux-x86_64-gnu/bin/python3.12 -m ensurepip --upgrade
|
||||
tar -C /opt -czf python-3.12-runtime.tar.gz python-3.12
|
||||
```
|
||||
|
||||
将 `python-3.12-runtime.tar.gz` 拷到内网服务器后解压到同一路径,例如 `/opt/python-3.12`,然后再用它创建虚拟环境:
|
||||
|
||||
```bash
|
||||
tar -C /opt -xzf python-3.12-runtime.tar.gz
|
||||
./uv venv .venv --python /opt/python-3.12/cpython-3.12.13-linux-x86_64-gnu/bin/python3.12
|
||||
./uv sync --frozen --offline
|
||||
```
|
||||
|
||||
如果你的准备机还没有现成的 `/opt/python-3.12`,就先从官方安装包、源码编译产物或已验证的便携发行版生成该目录,再做打包。
|
||||
|
||||
如果你不想使用绝对路径,也可以先把 `uv` 复制到 root 可见的位置:
|
||||
|
||||
```bash
|
||||
sudo cp /home/zjz/.local/bin/uv /usr/local/bin/uv
|
||||
sudo uv python install 3.12 --install-dir /opt/python-3.12
|
||||
```
|
||||
|
||||
## 3. 目标机落地
|
||||
|
||||
@@ -47,10 +86,16 @@ UV_CACHE_DIR=/opt/docx-analyzer/.uv-cache ./uv sync --frozen --offline
|
||||
如果系统没有满足版本的 Python:
|
||||
|
||||
```bash
|
||||
./uv venv .venv --python /opt/python/bin/python3.12
|
||||
./uv venv .venv --python /opt/python-3.12/cpython-3.12.13-linux-x86_64-gnu/bin/python3.12
|
||||
UV_CACHE_DIR=/opt/docx-analyzer/.uv-cache ./uv sync --frozen --offline
|
||||
```
|
||||
|
||||
如果内网机器不能使用 `uv sync` 拉取依赖,可直接用 wheel 包安装:
|
||||
|
||||
```bash
|
||||
/usr/bin/python3 -m pip install --no-index --find-links wheelhouse -r requirements.txt
|
||||
```
|
||||
|
||||
## 4. 启动与验证
|
||||
|
||||
启动服务:
|
||||
|
||||
Reference in New Issue
Block a user