hoyo-env 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. hoyo_env-0.1.0/.github/workflows/ci.yml +21 -0
  2. hoyo_env-0.1.0/.github/workflows/publish.yml +36 -0
  3. hoyo_env-0.1.0/.gitignore +7 -0
  4. hoyo_env-0.1.0/LICENSE +21 -0
  5. hoyo_env-0.1.0/PKG-INFO +163 -0
  6. hoyo_env-0.1.0/README.md +129 -0
  7. hoyo_env-0.1.0/pyproject.toml +64 -0
  8. hoyo_env-0.1.0/src/hoyo/__init__.py +10 -0
  9. hoyo_env-0.1.0/src/hoyo/__main__.py +4 -0
  10. hoyo_env-0.1.0/src/hoyo/catalog.py +275 -0
  11. hoyo_env-0.1.0/src/hoyo/channel.py +103 -0
  12. hoyo_env-0.1.0/src/hoyo/cli.py +411 -0
  13. hoyo_env-0.1.0/src/hoyo/config.py +160 -0
  14. hoyo_env-0.1.0/src/hoyo/download.py +247 -0
  15. hoyo_env-0.1.0/src/hoyo/errors.py +37 -0
  16. hoyo_env-0.1.0/src/hoyo/games.py +148 -0
  17. hoyo_env-0.1.0/src/hoyo/language.py +172 -0
  18. hoyo_env-0.1.0/src/hoyo/launcher.py +59 -0
  19. hoyo_env-0.1.0/src/hoyo/manager.py +450 -0
  20. hoyo_env-0.1.0/src/hoyo/models.py +57 -0
  21. hoyo_env-0.1.0/src/hoyo/progress.py +109 -0
  22. hoyo_env-0.1.0/src/hoyo/py.typed +1 -0
  23. hoyo_env-0.1.0/src/hoyo/sophon.py +107 -0
  24. hoyo_env-0.1.0/src/hoyo/sources.py +139 -0
  25. hoyo_env-0.1.0/src/hoyo/store.py +257 -0
  26. hoyo_env-0.1.0/tests/conftest.py +39 -0
  27. hoyo_env-0.1.0/tests/test_channel.py +33 -0
  28. hoyo_env-0.1.0/tests/test_cli.py +82 -0
  29. hoyo_env-0.1.0/tests/test_config.py +53 -0
  30. hoyo_env-0.1.0/tests/test_download.py +106 -0
  31. hoyo_env-0.1.0/tests/test_games.py +106 -0
  32. hoyo_env-0.1.0/tests/test_hoyo.py +175 -0
  33. hoyo_env-0.1.0/tests/test_language.py +74 -0
  34. hoyo_env-0.1.0/tests/test_launcher.py +59 -0
  35. hoyo_env-0.1.0/tests/test_manager.py +115 -0
  36. hoyo_env-0.1.0/tests/test_store.py +56 -0
  37. hoyo_env-0.1.0/uv.lock +500 -0
@@ -0,0 +1,21 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ jobs:
9
+ test:
10
+ runs-on: ${{ matrix.os }}
11
+ strategy:
12
+ fail-fast: false
13
+ matrix:
14
+ os: [ubuntu-latest, windows-latest]
15
+ steps:
16
+ - uses: actions/checkout@v7
17
+ - uses: astral-sh/setup-uv@v10.2.0
18
+ - run: uv python install 3.12
19
+ - run: uv sync --extra dev --frozen
20
+ - run: uv run ruff check src tests
21
+ - run: uv run pytest -q
@@ -0,0 +1,36 @@
1
+ name: Publish
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+ workflow_dispatch:
7
+
8
+ jobs:
9
+ test:
10
+ runs-on: ${{ matrix.os }}
11
+ strategy:
12
+ fail-fast: false
13
+ matrix:
14
+ os: [ubuntu-latest, windows-latest]
15
+ steps:
16
+ - uses: actions/checkout@v7
17
+ - uses: astral-sh/setup-uv@v10.2.0
18
+ - run: uv python install 3.12
19
+ - run: uv sync --extra dev --frozen
20
+ - run: uv run ruff check src tests
21
+ - run: uv run pytest -q
22
+
23
+ publish:
24
+ needs: test
25
+ runs-on: ubuntu-latest
26
+ permissions:
27
+ contents: read
28
+ steps:
29
+ - uses: actions/checkout@v7
30
+ - uses: astral-sh/setup-uv@v10.2.0
31
+ - name: Build
32
+ run: uv build
33
+ - name: Publish to PyPI
34
+ uses: pypa/gh-action-pypi-publish@v1.14.2
35
+ with:
36
+ password: ${{ secrets.PYPI_API_TOKEN }}
@@ -0,0 +1,7 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ .venv/
4
+ dist/
5
+ *.egg-info/
6
+ .pytest_cache/
7
+ .ruff_cache/
hoyo_env-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Qingrui Hu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,163 @@
1
+ Metadata-Version: 2.5
2
+ Name: hoyo-env
3
+ Version: 0.1.0
4
+ Summary: 米哈游游戏版本管理器:安装、切换、启动 hk4e / hkrpg / nap / bh3。下载集中存放,未改动文件不重复占用空间。
5
+ Project-URL: Homepage, https://github.com/invoker-bot/hoyo-env
6
+ Project-URL: Repository, https://github.com/invoker-bot/hoyo-env
7
+ Project-URL: Issues, https://github.com/invoker-bot/hoyo-env/issues
8
+ Author-email: Qingrui Hu <invoker-bot@outlook.com>
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: bh3,cli,genshin,hk4e,hkrpg,hoyo,hoyo-env,mihoyo,nap,version-manager
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: End Users/Desktop
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: Microsoft :: Windows
17
+ Classifier: Operating System :: POSIX
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Games/Entertainment
23
+ Requires-Python: >=3.11
24
+ Requires-Dist: httpx>=0.27
25
+ Requires-Dist: pydantic-settings>=2.3
26
+ Requires-Dist: pydantic>=2.7
27
+ Requires-Dist: rich>=13
28
+ Requires-Dist: typer>=0.12
29
+ Requires-Dist: zstandard>=0.23
30
+ Provides-Extra: dev
31
+ Requires-Dist: pytest>=8.0; extra == 'dev'
32
+ Requires-Dist: ruff>=0.6; extra == 'dev'
33
+ Description-Content-Type: text/markdown
34
+
35
+ # hoyo
36
+
37
+ PyPI 与 GitHub 上的项目名是 [hoyo-env](https://github.com/invoker-bot/hoyo-env)。`pip install hoyo-env` 之后,命令仍是 `hoyo`。
38
+
39
+ 米哈游 PC 游戏版本管理 CLI。支持:
40
+
41
+ | ID | 游戏 | 别名 | 语音 |
42
+ |----|------|------|------|
43
+ | `hk4e` | 原神 | `genshin`、`yuanshen`、`gi` | 独立语音包 |
44
+ | `hkrpg` | 崩坏:星穹铁道 | `hsr`、`starrail` | 含在本体 |
45
+ | `nap` | 绝区零 | `zzz` | 独立语音包 |
46
+ | `bh3` | 崩坏3 | `hi3`、`honkai3` | 含在本体 |
47
+
48
+ 各版本文件进**该游戏自己的内容寻址仓库**。下载和切换时:
49
+
50
+ - 已经有的文件(按 SHA-256)**不再下载**
51
+ - 工作副本用 **硬链接** 指向仓库,未改动文件**不复制**
52
+
53
+ ```text
54
+ hoyo games
55
+ hoyo versions hk4e
56
+ hoyo install hk4e 7.1.0
57
+ hoyo install hkrpg 4.6.0
58
+ hoyo install nap 3.2.0 -l ja
59
+ hoyo install bh3 9.1.0
60
+ hoyo switch hk4e 7.1.0
61
+ hoyo set language hk4e ja
62
+ hoyo launch hk4e
63
+ hoyo open hk4e
64
+ ```
65
+
66
+ `genshin install 5.3.0` 对应 `hoyo install hk4e 5.3.0`。`genshin`、`hsr`、`zzz`、`hi3` 只是游戏 ID 的别名。
67
+
68
+ 远程清单来自 [HoyoFiles](https://hoyo-files.amarea.cn/)(`autopatch.amarea.cn`),文件块来自官方 CDN。有直链时优先直链,否则走 Sophon Chunk。清单是国服;`--channel os` 只改写 `config.ini` 里的 `game_biz` / `cps`,不会换成国际服客户端。
69
+
70
+ 下载:
71
+
72
+ - **断点续传**:直链用 HTTP `Range` 接着 `.part` 写;Sophon chunk 缓存在 `cache/chunks/`
73
+ - **进度条**:Rich 显示总体/单文件进度、速度、剩余时间
74
+ - **并发**:默认同时下 4 个文件(asyncio + httpx),HTTP 连接上限 8。可用 `HOYO_FILE_CONCURRENCY` / `HOYO_HTTP_CONCURRENCY` 调整
75
+
76
+ 原神会写入 `audio_lang_*`,并在 Windows 上更新注册表里的 `deviceVoiceLanguageType` / `deviceLanguageType`。绝区零会另下所选语言的 `Audio_*_pkg_version`,但不会改注册表。星穹铁道和崩坏3没有这份独立语音清单。
77
+
78
+ ## 清单没有覆盖的资源
79
+
80
+ `hoyo install` 只下载 `pkg_version` 里的文件;原神和绝区零再加所选语言的 `Audio_*_pkg_version`。这是国服安装包的一份快照,不是游戏进程之后还会向服务器请求的全部文件。装完以后,下面没进清单的分类,以及快照之后服务器上新增的热更,仍可能要由游戏自己去下。
81
+
82
+ 对照示例版本(原神 7.1.0、星穹铁道 4.6.0、绝区零 3.2.0、崩坏3 9.1.0)的 Sophon 分类:
83
+
84
+ - **原神、星穹铁道的游戏资源**,以及**绝区零**清单里另列的主线、场景、活动、口型等分类,都已经写在 `pkg_version` 里,会一起下载。和对应 Sophon 分类相比,通常只少清单文件 `pkg_version` 自己。
85
+ - **崩坏3的 AssetBundle 不在包里。** `pkg_version` 只是约 1.6 GB 的客户端。正文在另一个分类 `asb`(约 34 GB,`BH3_Data/StreamingAssets/Asb/`),当前不会下载。第一次启动需要让游戏向服务器拉取。
86
+ - **星穹铁道的外置语音不在包里。** `Persistent/Audio/.../External*.pck` 属于 Sophon 的 `zh-cn` 等分类,不在本体 `pkg_version` 里,也没有 `Audio_*_pkg_version`。本体里已有的音频银行会下载;这套外置语音不会。进入游戏后仍可能向服务器下载。
87
+
88
+ ## 安装
89
+
90
+ 需要 Python 3.11+。
91
+
92
+ ```powershell
93
+ pip install hoyo-env
94
+ hoyo --help
95
+ ```
96
+
97
+ 从本仓库开发:
98
+
99
+ ```powershell
100
+ pip install -e ".[dev]"
101
+ ```
102
+
103
+ ## 命令
104
+
105
+ | 命令 | 作用 |
106
+ |------|------|
107
+ | `hoyo games` | 列出支持的游戏 |
108
+ | `hoyo versions <game>` | 列出清单中的版本 |
109
+ | `hoyo install <game> <version>` | 拉取缺失文件(含当前语言的语音包,若该游戏有独立语音包);开始前检查磁盘空间 |
110
+ | `hoyo install <game> <version> -l ja` | 安装时指定语音 |
111
+ | `hoyo install <game> <version> --from-dir <path>` | 从本地游戏目录导入 |
112
+ | `hoyo switch <game> <version>` | 把该游戏的当前目录切到该版本 |
113
+ | `hoyo launch <game>` | 启动该游戏当前版本 |
114
+ | `hoyo open <game>` | 在文件管理器中打开当前游戏目录 |
115
+ | `hoyo set language <game> <zh\|en\|ja\|ko>` | 记录语音。原神会同时切文本语言 |
116
+ | `hoyo set data-dir <path>` | 切换共享数据目录(省略参数则显示当前值) |
117
+ | `hoyo list [game]` | 列出已安装版本 |
118
+ | `hoyo status [game]` | 数据目录、当前版本、语音、仓库占用 |
119
+
120
+ 数据目录优先级:`--data-dir` > 环境变量 `HOYO_DATA_DIR` > `hoyo set data-dir` 写入的配置 > 系统默认。
121
+
122
+ 默认数据目录(未 `set` 过时):
123
+
124
+ - Windows:`%LOCALAPPDATA%\hoyo`
125
+ - Linux/macOS:`$XDG_DATA_HOME/hoyo` 或 `~/.local/share/hoyo`
126
+
127
+ 持久配置(只存数据目录在哪):
128
+
129
+ - Windows:`%APPDATA%\hoyo\config.json`
130
+ - Linux/macOS:`$XDG_CONFIG_HOME/hoyo/config.json` 或 `~/.config/hoyo/config.json`
131
+
132
+ ```powershell
133
+ hoyo set data-dir D:\Games\hoyo
134
+ hoyo set data-dir
135
+ hoyo status
136
+ ```
137
+
138
+ `set data-dir` **不会搬迁**已下载文件。换盘后请自行把旧目录拷到新位置,或重新 `install`。
139
+
140
+ 以前用 `genshin` 时,把旧数据目录里的内容移到新数据目录的 `hk4e` 子目录即可。旧清单没有 `game` 字段也能读。不要把旧的 `config.json` 直接拿来用:那里的 `data_dir` 指的是扁平目录,不是现在的共享根目录。
141
+
142
+ ## 磁盘布局
143
+
144
+ ```text
145
+ <data-dir>/
146
+ hk4e/
147
+ blobs/ab/abcd… # 内容寻址:每个唯一文件只存一份
148
+ manifests/<version>.json
149
+ versions/current/ # 唯一的游戏目录(硬链接工作副本)
150
+ state.json # 该游戏的当前版本号
151
+ tmp/
152
+ hkrpg/
153
+ nap/
154
+ bh3/
155
+ ```
156
+
157
+ 同一个版本号可以同时存在于不同游戏里,仓库互不混用。每个游戏只有一个可运行目录 `versions/current`,路径里不带版本号;`hoyo switch` 在这个目录里原地换成目标版本。
158
+
159
+ 切换时会对比目标清单与现有目录:哈希相同且已是指向仓库的硬链接则跳过;只增删、替换有变化的路径。
160
+
161
+ 日志、截图一类可变文件会**复制**而不是硬链接,避免游戏写入污染共享仓库。
162
+
163
+ 极早的版本若只剩整包 zip、没有直链/Chunk,目前还不能按文件抽取。
@@ -0,0 +1,129 @@
1
+ # hoyo
2
+
3
+ PyPI 与 GitHub 上的项目名是 [hoyo-env](https://github.com/invoker-bot/hoyo-env)。`pip install hoyo-env` 之后,命令仍是 `hoyo`。
4
+
5
+ 米哈游 PC 游戏版本管理 CLI。支持:
6
+
7
+ | ID | 游戏 | 别名 | 语音 |
8
+ |----|------|------|------|
9
+ | `hk4e` | 原神 | `genshin`、`yuanshen`、`gi` | 独立语音包 |
10
+ | `hkrpg` | 崩坏:星穹铁道 | `hsr`、`starrail` | 含在本体 |
11
+ | `nap` | 绝区零 | `zzz` | 独立语音包 |
12
+ | `bh3` | 崩坏3 | `hi3`、`honkai3` | 含在本体 |
13
+
14
+ 各版本文件进**该游戏自己的内容寻址仓库**。下载和切换时:
15
+
16
+ - 已经有的文件(按 SHA-256)**不再下载**
17
+ - 工作副本用 **硬链接** 指向仓库,未改动文件**不复制**
18
+
19
+ ```text
20
+ hoyo games
21
+ hoyo versions hk4e
22
+ hoyo install hk4e 7.1.0
23
+ hoyo install hkrpg 4.6.0
24
+ hoyo install nap 3.2.0 -l ja
25
+ hoyo install bh3 9.1.0
26
+ hoyo switch hk4e 7.1.0
27
+ hoyo set language hk4e ja
28
+ hoyo launch hk4e
29
+ hoyo open hk4e
30
+ ```
31
+
32
+ `genshin install 5.3.0` 对应 `hoyo install hk4e 5.3.0`。`genshin`、`hsr`、`zzz`、`hi3` 只是游戏 ID 的别名。
33
+
34
+ 远程清单来自 [HoyoFiles](https://hoyo-files.amarea.cn/)(`autopatch.amarea.cn`),文件块来自官方 CDN。有直链时优先直链,否则走 Sophon Chunk。清单是国服;`--channel os` 只改写 `config.ini` 里的 `game_biz` / `cps`,不会换成国际服客户端。
35
+
36
+ 下载:
37
+
38
+ - **断点续传**:直链用 HTTP `Range` 接着 `.part` 写;Sophon chunk 缓存在 `cache/chunks/`
39
+ - **进度条**:Rich 显示总体/单文件进度、速度、剩余时间
40
+ - **并发**:默认同时下 4 个文件(asyncio + httpx),HTTP 连接上限 8。可用 `HOYO_FILE_CONCURRENCY` / `HOYO_HTTP_CONCURRENCY` 调整
41
+
42
+ 原神会写入 `audio_lang_*`,并在 Windows 上更新注册表里的 `deviceVoiceLanguageType` / `deviceLanguageType`。绝区零会另下所选语言的 `Audio_*_pkg_version`,但不会改注册表。星穹铁道和崩坏3没有这份独立语音清单。
43
+
44
+ ## 清单没有覆盖的资源
45
+
46
+ `hoyo install` 只下载 `pkg_version` 里的文件;原神和绝区零再加所选语言的 `Audio_*_pkg_version`。这是国服安装包的一份快照,不是游戏进程之后还会向服务器请求的全部文件。装完以后,下面没进清单的分类,以及快照之后服务器上新增的热更,仍可能要由游戏自己去下。
47
+
48
+ 对照示例版本(原神 7.1.0、星穹铁道 4.6.0、绝区零 3.2.0、崩坏3 9.1.0)的 Sophon 分类:
49
+
50
+ - **原神、星穹铁道的游戏资源**,以及**绝区零**清单里另列的主线、场景、活动、口型等分类,都已经写在 `pkg_version` 里,会一起下载。和对应 Sophon 分类相比,通常只少清单文件 `pkg_version` 自己。
51
+ - **崩坏3的 AssetBundle 不在包里。** `pkg_version` 只是约 1.6 GB 的客户端。正文在另一个分类 `asb`(约 34 GB,`BH3_Data/StreamingAssets/Asb/`),当前不会下载。第一次启动需要让游戏向服务器拉取。
52
+ - **星穹铁道的外置语音不在包里。** `Persistent/Audio/.../External*.pck` 属于 Sophon 的 `zh-cn` 等分类,不在本体 `pkg_version` 里,也没有 `Audio_*_pkg_version`。本体里已有的音频银行会下载;这套外置语音不会。进入游戏后仍可能向服务器下载。
53
+
54
+ ## 安装
55
+
56
+ 需要 Python 3.11+。
57
+
58
+ ```powershell
59
+ pip install hoyo-env
60
+ hoyo --help
61
+ ```
62
+
63
+ 从本仓库开发:
64
+
65
+ ```powershell
66
+ pip install -e ".[dev]"
67
+ ```
68
+
69
+ ## 命令
70
+
71
+ | 命令 | 作用 |
72
+ |------|------|
73
+ | `hoyo games` | 列出支持的游戏 |
74
+ | `hoyo versions <game>` | 列出清单中的版本 |
75
+ | `hoyo install <game> <version>` | 拉取缺失文件(含当前语言的语音包,若该游戏有独立语音包);开始前检查磁盘空间 |
76
+ | `hoyo install <game> <version> -l ja` | 安装时指定语音 |
77
+ | `hoyo install <game> <version> --from-dir <path>` | 从本地游戏目录导入 |
78
+ | `hoyo switch <game> <version>` | 把该游戏的当前目录切到该版本 |
79
+ | `hoyo launch <game>` | 启动该游戏当前版本 |
80
+ | `hoyo open <game>` | 在文件管理器中打开当前游戏目录 |
81
+ | `hoyo set language <game> <zh\|en\|ja\|ko>` | 记录语音。原神会同时切文本语言 |
82
+ | `hoyo set data-dir <path>` | 切换共享数据目录(省略参数则显示当前值) |
83
+ | `hoyo list [game]` | 列出已安装版本 |
84
+ | `hoyo status [game]` | 数据目录、当前版本、语音、仓库占用 |
85
+
86
+ 数据目录优先级:`--data-dir` > 环境变量 `HOYO_DATA_DIR` > `hoyo set data-dir` 写入的配置 > 系统默认。
87
+
88
+ 默认数据目录(未 `set` 过时):
89
+
90
+ - Windows:`%LOCALAPPDATA%\hoyo`
91
+ - Linux/macOS:`$XDG_DATA_HOME/hoyo` 或 `~/.local/share/hoyo`
92
+
93
+ 持久配置(只存数据目录在哪):
94
+
95
+ - Windows:`%APPDATA%\hoyo\config.json`
96
+ - Linux/macOS:`$XDG_CONFIG_HOME/hoyo/config.json` 或 `~/.config/hoyo/config.json`
97
+
98
+ ```powershell
99
+ hoyo set data-dir D:\Games\hoyo
100
+ hoyo set data-dir
101
+ hoyo status
102
+ ```
103
+
104
+ `set data-dir` **不会搬迁**已下载文件。换盘后请自行把旧目录拷到新位置,或重新 `install`。
105
+
106
+ 以前用 `genshin` 时,把旧数据目录里的内容移到新数据目录的 `hk4e` 子目录即可。旧清单没有 `game` 字段也能读。不要把旧的 `config.json` 直接拿来用:那里的 `data_dir` 指的是扁平目录,不是现在的共享根目录。
107
+
108
+ ## 磁盘布局
109
+
110
+ ```text
111
+ <data-dir>/
112
+ hk4e/
113
+ blobs/ab/abcd… # 内容寻址:每个唯一文件只存一份
114
+ manifests/<version>.json
115
+ versions/current/ # 唯一的游戏目录(硬链接工作副本)
116
+ state.json # 该游戏的当前版本号
117
+ tmp/
118
+ hkrpg/
119
+ nap/
120
+ bh3/
121
+ ```
122
+
123
+ 同一个版本号可以同时存在于不同游戏里,仓库互不混用。每个游戏只有一个可运行目录 `versions/current`,路径里不带版本号;`hoyo switch` 在这个目录里原地换成目标版本。
124
+
125
+ 切换时会对比目标清单与现有目录:哈希相同且已是指向仓库的硬链接则跳过;只增删、替换有变化的路径。
126
+
127
+ 日志、截图一类可变文件会**复制**而不是硬链接,避免游戏写入污染共享仓库。
128
+
129
+ 极早的版本若只剩整包 zip、没有直链/Chunk,目前还不能按文件抽取。
@@ -0,0 +1,64 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "hoyo-env"
7
+ version = "0.1.0"
8
+ description = "米哈游游戏版本管理器:安装、切换、启动 hk4e / hkrpg / nap / bh3。下载集中存放,未改动文件不重复占用空间。"
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ authors = [{ name = "Qingrui Hu", email = "invoker-bot@outlook.com" }]
14
+ keywords = ["hoyo", "hoyo-env", "mihoyo", "hk4e", "hkrpg", "nap", "bh3", "genshin", "version-manager", "cli"]
15
+ classifiers = [
16
+ "Development Status :: 3 - Alpha",
17
+ "Environment :: Console",
18
+ "Intended Audience :: End Users/Desktop",
19
+ "License :: OSI Approved :: MIT License",
20
+ "Operating System :: Microsoft :: Windows",
21
+ "Operating System :: POSIX",
22
+ "Programming Language :: Python :: 3",
23
+ "Programming Language :: Python :: 3.11",
24
+ "Programming Language :: Python :: 3.12",
25
+ "Programming Language :: Python :: 3.13",
26
+ "Topic :: Games/Entertainment",
27
+ ]
28
+ dependencies = [
29
+ "httpx>=0.27",
30
+ "pydantic>=2.7",
31
+ "pydantic-settings>=2.3",
32
+ "rich>=13",
33
+ "typer>=0.12",
34
+ "zstandard>=0.23",
35
+ ]
36
+
37
+ [project.optional-dependencies]
38
+ dev = [
39
+ "pytest>=8.0",
40
+ "ruff>=0.6",
41
+ ]
42
+
43
+ [project.urls]
44
+ Homepage = "https://github.com/invoker-bot/hoyo-env"
45
+ Repository = "https://github.com/invoker-bot/hoyo-env"
46
+ Issues = "https://github.com/invoker-bot/hoyo-env/issues"
47
+
48
+ [project.scripts]
49
+ hoyo = "hoyo.cli:app"
50
+
51
+ [tool.hatch.build.targets.wheel]
52
+ packages = ["src/hoyo"]
53
+
54
+ [tool.pytest.ini_options]
55
+ testpaths = ["tests"]
56
+ pythonpath = ["src"]
57
+
58
+ [tool.ruff]
59
+ target-version = "py311"
60
+ line-length = 100
61
+ src = ["src", "tests"]
62
+
63
+ [tool.ruff.lint]
64
+ select = ["E", "F", "I", "UP", "B"]
@@ -0,0 +1,10 @@
1
+ """米哈游游戏版本管理器。"""
2
+
3
+ from importlib.metadata import PackageNotFoundError, version
4
+
5
+ try:
6
+ __version__ = version("hoyo-env")
7
+ except PackageNotFoundError: # pragma: no cover - editable/uninstalled fallback
8
+ __version__ = "0.1.0"
9
+
10
+ __all__ = ["__version__"]
@@ -0,0 +1,4 @@
1
+ from hoyo.cli import app
2
+
3
+ if __name__ == "__main__":
4
+ app()