Skip to content

Commit b84aa1a

Browse files
committed
迁移到 uv 管理文档依赖
1 parent 1ad146e commit b84aa1a

11 files changed

Lines changed: 428 additions & 79 deletions

File tree

.github/workflows/pages.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,19 @@ jobs:
2323
- name: Checkout
2424
uses: actions/checkout@v4
2525

26+
- name: Set up uv
27+
uses: astral-sh/setup-uv@v8
28+
2629
- name: Set up Python
2730
uses: actions/setup-python@v5
2831
with:
29-
python-version: "3.8"
32+
python-version: "3.12"
3033

3134
- name: Configure Pages
3235
uses: actions/configure-pages@v5
3336

3437
- name: Install dependencies
35-
run: make install
38+
run: uv sync --python 3.12 --frozen --no-install-project
3639

3740
- name: Build documentation
3841
run: make html

Makefile

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.DEFAULT_GOAL := help
22

3-
PYENV_PYTHON := $(shell if command -v pyenv >/dev/null 2>&1 && pyenv versions --bare | grep -qx '3.8.13'; then printf 'PYENV_VERSION=3.8.13 pyenv exec python'; fi)
4-
PYTHON ?= $(if $(PYENV_PYTHON),$(PYENV_PYTHON),python3)
3+
UV ?= uv
4+
PYTHON_VERSION ?= 3.12
55
VENV ?= .venv
66
PORT ?= 8005
77

@@ -16,7 +16,7 @@ DOC_TARGETS := dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex
1616

1717
help:
1818
@echo "Please use \`make <target>' where <target> is one of"
19-
@echo " install create $(VENV) and install dependencies"
19+
@echo " install create $(VENV) with uv and install dependencies"
2020
@echo " html build standalone HTML files"
2121
@echo " serve build and serve docs at http://localhost:$(PORT)/"
2222
@echo " clean remove generated documentation files"
@@ -25,11 +25,9 @@ help:
2525

2626
install: $(INSTALL_STAMP)
2727

28-
$(INSTALL_STAMP): requirements.txt
29-
@test -n "$(PYTHON)" || (echo "python3 is required" && exit 1)
30-
$(PYTHON) -m venv $(VENV)
31-
$(VENV_PYTHON) -m pip install --upgrade pip
32-
$(VENV_PYTHON) -m pip install -r requirements.txt
28+
$(INSTALL_STAMP): pyproject.toml uv.lock Makefile
29+
@command -v $(UV) >/dev/null 2>&1 || (echo "uv is required. Install it from https://docs.astral.sh/uv/" && exit 1)
30+
$(UV) sync --python $(PYTHON_VERSION) --frozen --no-install-project
3331
@touch $(INSTALL_STAMP)
3432

3533
build: html

Pipfile

Lines changed: 0 additions & 30 deletions
This file was deleted.

Readme.rst

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Python最佳实践指南中文版
1414

1515
项目翻译来自 `Hitchhiker's Guide to Python <https://github.com/kennethreitz/python-guide>`_。
1616

17-
GitHub Pages 文档地址 `Python最佳实践指南中文版 <https://prodesire.github.io/Python-Guide-CN/>`_。
17+
文档地址 `Python最佳实践指南中文版 <https://prodesire.github.io/Python-Guide-CN/>`_。
1818

1919
-----------
2020

@@ -37,22 +37,14 @@ GitHub Pages 文档地址 `Python最佳实践指南中文版 <https://prodesire.
3737
- 测试: Jenkins & tox 指南
3838
- 如何更方便地通过 ``git`` 连接 ``hg``
3939

40-
如果您不习惯阅读reStructuredText形式的文档, 这里有一份同步更新的 `HTML版文档,请戳它 <https://prodesire.github.io/Python-Guide-CN/>`_。
41-
42-
4340
使用指南
4441
============================
4542
1. 下载zip文件或clone到本地,并进入到项目根目录
4643
2. 打开命令行,运行 ``make help`` 查看可用命令
47-
3. 打开命令行,运行 ``make install`` 创建虚拟环境并安装依赖
44+
3. 打开命令行,运行 ``make install`` 使用 uv 根据 ``pyproject.toml`` 创建虚拟环境并安装依赖
4845
4. 打开命令行,运行 ``make html`` 构建文档;或运行 ``make serve`` 构建并启动本地文档网站
4946
5. ``make html`` 会在 ``docs/_build/html`` 中生成 HTML 文件,``make serve`` 默认会在 ``http://localhost:8005/`` 运行文档网站
5047

51-
或者
52-
---------------------------
53-
- 直接访问 `Python最佳实践指南中文版 <https://prodesire.github.io/Python-Guide-CN/>`_。
54-
55-
5648
翻译指南
5749
============================
5850
1. 将 `python-guide <https://github.com/kennethreitz/python-guide>`_ 项目和本项目的master分支更新

TODO.rst

Lines changed: 0 additions & 3 deletions
This file was deleted.

docs/notes/contribute.rst

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ Python-guide目前还在开发中,欢迎大家贡献代码。
2323
要做的事
2424
*********
2525

26-
如果您想为我们做些贡献,这里有我们的计划。一个简短的 todo_ 列表。
27-
28-
.. include:: ../../TODO.rst
26+
如果您想为我们做些贡献,请查看 GitHub_ 上的 issue 列表。
2927

3028

3129
.. _GitHub: https://github.com/kennethreitz/python-guide/
32-
.. _todo: https://github.com/kennethreitz/python-guide/blob/master/TODO.rst

pyproject.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[project]
2+
name = "python-guide-cn"
3+
version = "0.0.0"
4+
description = "Chinese translation of The Hitchhiker's Guide to Python"
5+
requires-python = ">=3.12"
6+
dependencies = [
7+
"sphinx>=7.4,<8",
8+
"sphinx-sitemap>=2.9,<3",
9+
"sphinxcontrib-websupport>=2,<3",
10+
]
11+
12+
[tool.uv]
13+
package = false

requirements-to-freeze.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

requirements.txt

Lines changed: 0 additions & 20 deletions
This file was deleted.

runtime.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)