From add187f8d8c7ff7d231fcbee45cbb4f1ed247d3a Mon Sep 17 00:00:00 2001 From: vain-Liang <127164184+vain-Liang@users.noreply.github.com> Date: Mon, 3 Nov 2025 19:55:52 +0800 Subject: [PATCH] feat: basic support for running with uv (#1265) --- .gitignore | 2 +- README.md | 95 ++++++++++++++++++++++++++++++++++++++++++++++++-- pyproject.toml | 23 ++++++++++++ 3 files changed, 117 insertions(+), 3 deletions(-) create mode 100644 pyproject.toml diff --git a/.gitignore b/.gitignore index ac82d13..1496437 100644 --- a/.gitignore +++ b/.gitignore @@ -90,7 +90,7 @@ node-v*.zip # pyenv # For a library or package, you might want to ignore these files since the code is # intended to run in multiple environments; otherwise, check them in: -# .python-version +.python-version # pipenv # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. diff --git a/README.md b/README.md index 6d542e7..8e0a31b 100644 --- a/README.md +++ b/README.md @@ -287,7 +287,7 @@ https://www.picarto.tv/cuteavalanche   ## 🎃源码运行 -使用源码运行,前提要有**Python>=3.10**环境,如果没有请先自行安装Python,再执行下面步骤。 +使用源码运行,可参考下面的步骤。 1.首先拉取或手动下载本仓库项目代码 @@ -299,9 +299,94 @@ git clone https://github.com/ihmily/DouyinLiveRecorder.git ```bash cd DouyinLiveRecorder -pip3 install -r requirements.txt ``` +> [!TIP] +> - 不论你是否已安装 **Python>=3.10** 环境, 都推荐使用 [**uv**](https://github.com/astral-sh/uv) 运行, 因为它可以自动管理虚拟环境和方便地管理 **Python** 版本, **不过这完全是可选的**
+> 使用以下命令安装 +> ```bash +> # 在 macOS 和 Linux 上安装 uv +> curl -LsSf https://astral.sh/uv/install.sh | sh +> ``` +> ```powershell +> # 在 Windows 上安装 uv +> powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" +> ``` +> - 如果安装依赖速度太慢, 你可以考虑使用国内 pip 镜像源:
+> 在 `pip` 命令使用 `-i` 参数指定, 如 `pip3 install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple`
+> 或者在 `uv` 命令 `--index` 选项指定, 如 `uv sync --index https://pypi.tuna.tsinghua.edu.cn/simple` + +
+ + 如果已安装 Python>=3.10 环境 + + - :white_check_mark: 在虚拟环境中安装 (推荐) + + 1. 创建虚拟环境 + + - 使用系统已安装的 Python, 不使用 uv + + ```bash + python -m venv .venv + ``` + + - 使用 uv, 默认使用系统 Python, 你可以添加 `--python` 选项指定 Python 版本而不使用系统 Python [uv官方文档](https://docs.astral.sh/uv/concepts/python-versions/) + + ```bash + uv venv + ``` + + 2. 在终端激活虚拟环境 (在未安装 uv 或你想要手动激活虚拟环境时执行, 若已安装 uv, 可以跳过这一步, uv 会自动激活并使用虚拟环境) + + **Bash** 中 + ```bash + source .venv/Scripts/activate + ``` + + **Powershell** 中 + ```powershell + .venv\Scripts\activate.ps1 + ``` + + **Windows CMD** 中 + ```bat + .venv\Scripts\activate.bat + ``` + + 3. 安装依赖 + + ```bash + # 使用 pip (若安装太慢或失败, 可使用 `-i` 指定镜像源) + pip3 install -U pip && pip3 install -r requirements.txt + # 或者使用 uv (可使用 `--index` 指定镜像源) + uv sync + # 或者 + uv pip sync requirements.txt + ``` + + - :x: 在系统 Python 环境中安装 (不推荐) + + ```bash + pip3 install -U pip && pip3 install -r requirements.txt + ``` + +
+ +
+ + 如果未安装 Python>=3.10 环境 + + 你可以使用 [**uv**](https://github.com/astral-sh/uv) 安装依赖 + + ```bash + # uv 将使用 3.10 及以上的最新 python 发行版自动创建并使用虚拟环境, 可使用 --python 选项指定 python 版本, 参见 https://docs.astral.sh/uv/reference/cli/#uv-sync--python 和 https://docs.astral.sh/uv/reference/cli/#uv-pip-sync--python + uv sync + # 或 + uv pip sync requirements.txt + ``` + +
+ 3.安装[FFmpeg](https://ffmpeg.org/download.html#build-linux),如果是Windows系统,这一步可跳过。对于Linux系统,执行以下命令安装 CentOS执行 @@ -334,6 +419,12 @@ brew install ffmpeg ```python python main.py + +``` +或 + +```bash +uv run main.py ``` 其中Linux系统请使用`python3 main.py` 运行。 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..b2340a6 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,23 @@ +[project] +name = "DouyinLiveRecorder" +version = "4.0.7" +description = "可循环值守和多人录制的直播录制软件, 支持抖音、TikTok、Youtube、快手、虎牙、斗鱼、B站、小红书、pandatv、sooplive、flextv、popkontv、twitcasting、winktv、百度、微博、酷狗、17Live、Twitch、Acfun、CHZZK、shopee等40+平台直播录制" +readme = "README.md" +authors = [{name = "Hmily"}] +license = { text = "MIT" } +requires-python = ">=3.10" +dependencies = [ + "requests>=2.31.0", + "loguru>=0.7.3", + "pycryptodome>=3.20.0", + "distro>=1.9.0", + "tqdm>=4.67.1", + "httpx[http2]>=0.28.1", + "PyExecJS>=1.5.1" +] + +[project.urls] +"Homepage" = "https://github.com/ihmily/DouyinLiveRecorder" +"Documentation" = "https://github.com/ihmily/DouyinLiveRecorder" +"Repository" = "https://github.com/ihmily/DouyinLiveRecorder" +"Issues" = "https://github.com/ihmily/DouyinLiveRecorder/issues"