Skip to content

The only downloader you need. 下载器的集大成者。

fix(ci): arm64 runner 只有 VS 2026,libtorrent 用最新 Boost 编译,cmake 不写死生成器

XiaoYouChRcb98b65feaca
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 8279de2d..69dafd87 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -202,6 +202,8 @@ jobs:
- name: Build libtorrent wheel
if: ${{ matrix.architecture == 'arm64' && steps.libtorrent-cache.outputs.cache-hit != 'true' }}
+ # b2 找不到编译器时会卡住而不是报错
+ timeout-minutes: 120
run: uv run --no-sync python scripts/build_libtorrent_wheel.py "${{ steps.libtorrent.outputs.version }}" "${{ steps.libtorrent.outputs.python }}" libtorrent-wheel
- name: Install libtorrent wheel
@@ -224,14 +226,14 @@ jobs:
- name: Build updater
shell: pwsh
run: |
- cmake -B build-updater -G "Visual Studio 17 2022" -A ${{ matrix.msvc_arch }} tools/updater
+ cmake -B build-updater -A ${{ matrix.msvc_arch }} tools/updater
cmake --build build-updater --config Release
Copy-Item build-updater/Release/updater.exe dist/Ghost-Downloader-3.dist/
- name: Build ghd
shell: pwsh
run: |
- cmake -B build-ghd -G "Visual Studio 17 2022" -A ${{ matrix.msvc_arch }} tools/ghd
+ cmake -B build-ghd -A ${{ matrix.msvc_arch }} tools/ghd
cmake --build build-ghd --config Release
New-Item -ItemType Directory -Force dist/Ghost-Downloader-3.dist/bin
Copy-Item build-ghd/Release/ghd.exe dist/Ghost-Downloader-3.dist/bin/
diff --git a/scripts/build_libtorrent_wheel.py b/scripts/build_libtorrent_wheel.py
index c1ee5ecf..d45775a4 100644
--- a/scripts/build_libtorrent_wheel.py
+++ b/scripts/build_libtorrent_wheel.py
@@ -1,19 +1,23 @@
#!/usr/bin/env python3
"""Build the libtorrent win_arm64 wheel from the upstream tag.
-PyPI has no win_arm64 wheel. Boost and OpenSSL versions follow the upstream
-tag's own cibuildwheel config, so the wheel matches the x64 one on PyPI.
+PyPI has no win_arm64 wheel. OpenSSL follows the upstream tag's own
+cibuildwheel config, so the wheel matches the x64 one on PyPI. Boost uses the
+latest release instead of the upstream one, because the windows-11-arm runner
+only has Visual Studio 2026, and b2 knows it since Boost 1.91.
Usage:
python scripts/build_libtorrent_wheel.py <libtorrent version> <python version> <output folder>
"""
import os
+import re
import shutil
import subprocess
import sys
from pathlib import Path
UPSTREAM = "https://github.com/arvidn/libtorrent.git"
+BOOST = "https://github.com/boostorg/boost.git"
OPENSSL_FOLDER = Path(r"C:\Program Files\OpenSSL")
@@ -21,6 +25,13 @@ def run(*args: str, cwd: Path | None = None, env: dict[str, str] | None = None)
subprocess.run(args, cwd=cwd, env=env, check=True)
+def fetchLatestBoostVersion() -> str:
+ tags = subprocess.run(("git", "ls-remote", "--tags", "--refs", BOOST, "boost-*"),
+ capture_output=True, text=True, check=True).stdout
+ versions = re.findall(r"refs/tags/boost-(\d+\.\d+\.\d+)$", tags, re.MULTILINE)
+ return max(versions, key=lambda v: tuple(map(int, v.split("."))))
+
+
def main() -> None:
version, pythonVersion, outputFolder = sys.argv[1:]
source = Path(os.environ["RUNNER_TEMP"]) / "libtorrent"
@@ -39,7 +50,7 @@ def main() -> None:
"CIBW_BUILD": f"cp{pythonVersion.replace('.', '')}-win_arm64",
"CIBW_ARCHS_WINDOWS": "ARM64",
# 上游只给 win32、win_amd64 配了装 Boost 的 before-all
- "CIBW_BEFORE_ALL_WINDOWS": "bash -c './tools/cibuildwheel/setup_boost.sh $BOOST_VERSION $BOOST_ROOT'",
+ "CIBW_BEFORE_ALL_WINDOWS": f"bash -c './tools/cibuildwheel/setup_boost.sh {fetchLatestBoostVersion()} $BOOST_ROOT'",
"CIBW_TEST_SKIP": "*",
}
run("uvx", "cibuildwheel", "--output-dir", str(Path(outputFolder).resolve()), cwd=source, env=env)