Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/PR-test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ---------------------------------------------------------------
# Workflow File : PR-test.yml
# File Authors : 曾奥然 <ccmywish@qq.com>
# Contributors : Mikachu2333 <mikachu2333@zohomail.com>
# File Authors : 曾奥然 <ccmywish@qq.com>
# Contributors : Mikachu2333 <linkchou@yandex.com>
# |
# Created On : <2025-06-19>
# Last Modified : <2025-08-17>
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
*.out
*.exe
*.res
*.pdb


##############################
Expand Down
5 changes: 5 additions & 0 deletions .vscode/settings.json
Comment thread
Mikachu2333 marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,9 @@
},

"vscode-just.formatOnSave": false,

"clangd.enable": false,
"clangd.enableCodeCompletion": false,
"clangd.enableHover": false,
"clangd.detectExtensionConflicts": false
}
4 changes: 2 additions & 2 deletions doc/10-如何编写recipe.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
! -------------------------------------------------------------
! Doc Type : Markdown
! Doc Name : 10-如何编写recipe.md
! Doc Authors : 曾奥然 <ccmywish@qq.com>
! Contributors : Nul None <nul@none.org>
! Doc Authors : 曾奥然 <ccmywish@qq.com>
! Contributors : Mikachu2333 <linkchou@yandex.com>
! |
! Created On : <2024-08-19>
! Last Modified : <2026-01-21>
Expand Down
3 changes: 2 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
# 而不清楚 just 在 MINGW32 中的情况,所以我们在此 justfile 中并不实现关于 CI 的功能
# --------------------------------------------------------------

set windows-shell := ['cmd', '/c']
[windows]
set shell := ['cmd', '/c']

CC := if os() == 'windows' {
"gcc"
Expand Down
8 changes: 4 additions & 4 deletions lib/xy.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
* Copyright © 2023-2026 曾奥然, 郭恒
* SPDX-License-Identifier: MIT
* -------------------------------------------------------------
* Lib Authors : 曾奥然 <ccmywish@qq.com>
* | 郭恒 <2085471348@qq.com>
* Contributors : Mikachu2333 <mikachu.23333@zohomail.com>
* Lib Authors : 曾奥然 <ccmywish@qq.com>
* | 郭恒 <2085471348@qq.com>
* Contributors : Mikachu2333 <linkchou@yandex.com>
* | juzeon <skyjuzheng@gmail.com>
* | BingChunMoLi <bingchunmoli@bingchunmoli.com>
* | AnonTokio <anontokio@163.com>
Expand Down Expand Up @@ -762,7 +762,7 @@ xy_str_next_nonempty_line (const char *str)
/**
* @brief 读取文件内容并返回字符串,失败时返回空字符串
*
* @note 已处理 \r\n 和 \r,返回的字符串均为 \n 换行
* @note 已处理 `\r\n``\r`,返回的字符串均为 `\n` 换行
*
* @flavor Ruby: IO::read
*
Expand Down
2 changes: 1 addition & 1 deletion src/chsrc-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ chsrc_register_contributors ()
chef_register_contributor ("@Kattos", "ccy", "icuichengyi@gmail.com", NULL);
chef_register_contributor ("@xrgzs", "MadDogOwner", "xiaoran@xrgzs.top", NULL);
chef_register_contributor ("@sanchuanhehe", "sanchuanhehe", "wyihe5520@gmail.com", NULL);
chef_register_contributor ("@Mikachu2333", "Mikachu2333", "mikachu.23333@zohomail.com", NULL);
chef_register_contributor ("@Mikachu2333", "Mikachu2333", "linkchou@yandex.com", NULL);
chef_register_contributor ("@techoc", "Rui Yang", "techoc@foxmail.com", NULL);
chef_register_contributor ("@BingChunMoLi", "BingChunMoLi", "bingchunmoli@bingchunmoli.com", NULL);
chef_register_contributor ("@wcbing", "wcbing", "i@wcbing.top", NULL);
Expand Down
8 changes: 4 additions & 4 deletions src/recipe/lang/Python/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ pl_python_group_prelude (void)
// @ref https://mirrors.jlu.edu.cn/_news/#2025-04-06-pypi-repo-down
// {&Jlu, "https://mirrors.jlu.edu.cn/pypi/web/simple", FeedByPrelude},
{&Sjtug_Siyuan, "https://mirror.sjtu.edu.cn/pypi/web/simple", FeedByPrelude},
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple",FeedByPrelude},
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple", FeedByPrelude},
{&Ustc, "https://mirrors.ustc.edu.cn/pypi/simple", FeedByPrelude},
{&Ali, "https://mirrors.aliyun.com/pypi/simple", FeedByPrelude},
{&Nju, "https://mirror.nju.edu.cn/pypi/web/simple", FeedByPrelude},
{&Pku, "https://mirrors.pku.edu.cn/pypi/web/simple", FeedByPrelude},
{&Tencent, "https://mirrors.cloud.tencent.com/pypi/simple", FeedByPrelude},

// {&Tencent_Intra, "https://mirrors.cloud.tencentyun.com/pypi/simple",FeedByPrelude}
{&Huawei, "https://mirrors.huaweicloud.com/repository/pypi/simple",FeedByPrelude},
{&Hust, "https://mirrors.hust.edu.cn/pypi/web/simple",FeedByPrelude}
// {&Tencent_Intra, "https://mirrors.cloud.tencentyun.com/pypi/simple", FeedByPrelude}
{&Huawei, "https://mirrors.huaweicloud.com/repository/pypi/simple", FeedByPrelude},
{&Hust, "https://mirrors.hust.edu.cn/pypi/web/simple", FeedByPrelude}

/* 不启用原因:24小时更新一次 */
// {&Netease, "https://mirrors.163.com/.help/pypi.html", NULL}
Expand Down
196 changes: 0 additions & 196 deletions src/recipe/lang/Python/uv.c

This file was deleted.

77 changes: 77 additions & 0 deletions src/recipe/lang/Python/uv/README.md
Comment thread
Mikachu2333 marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<!-- -----------------------------------------------------------
! SPDX-License-Identifier: GFDL-1.3-or-later
! -------------------------------------------------------------
! Doc Type : Markdown
! Doc Name : uv换源实现说明.md
! Created On : <2026-08-02>
! Last Modified : <2026-08-02>
! ---------------------------------------------------------- -->

# uv 换源实现说明

`chsrc set uv` 同时配置两类下载地址:

1. Python 包索引,即 `uv.toml` 的 `[[index]]` 或 `pyproject.toml` 的 `[[tool.uv.index]]`
2. uv 管理的 CPython 下载地址,即 `python-install-mirror`

<br>

## 配置文件选择

项目作用域只修改当前目录,不向父目录查找并修改配置:

1. 当前目录存在 `uv.toml` 时修改 `uv.toml`
2. 否则,当前目录存在 `pyproject.toml` 时修改其中的 `[tool.uv]`
3. 两者都不存在时创建 `uv.toml`

这个顺序与 uv 的行为一致:同一目录同时存在 `uv.toml` 与 `pyproject.toml` 的 `[tool.uv]` 时,uv 优先使用 `uv.toml` 中的对应字段。

用户作用域使用 uv 的用户配置目录:Windows 为 `%APPDATA%\uv\uv.toml`,Linux 和 macOS 优先使用 `$XDG_CONFIG_HOME/uv/uv.toml`,未设置时使用 `~/.config/uv/uv.toml`。

<br>

## Python 包索引

索引 URL 必须指向兼容 Python Simple Repository API 的地址,通常以 `/simple` 结尾;uv 不要求 URL 必须以 `/` 结尾。

`default = true` 表示该 index 替代 uv 内置的 PyPI,并且始终具有最低 index 优先级。它不表示“文本中的第一个”或“最高优先级”。配置中存在多个 index 时,chsrc 优先更新 `default = true` 的 index;没有 default index 时才更新第一个 index。

默认的 `first-index` 策略会在第一个包含目标包的 index 停止搜索。私有源与公共镜像并存时,不应把它理解成跨所有 index 选择全局最新版本。

<br>

## Python 下载镜像

`python-install-mirror` 是 `https://github.com/astral-sh/python-build-standalone/releases/download` 的替换前缀。配置值必须是镜像侧对应的 `releases/download` 基址,不能是仓库主页、某个具体构建日期或某个归档文件。uv 会在其后追加构建日期和
归档文件名。

官方示例使用不带尾部 `/` 的基址,chsrc 内置源也遵循该形式。

<br>

## reset 与备份

`chsrc set uv` 修改已有配置前会创建 `.bak` 备份。

`chsrc reset uv` 把 chsrc 管理的 index 与 `python-install-mirror` 写回默认上游:index 恢复为 `https://pypi.org/simple`,
`python-install-mirror` 恢复为 `https://github.com/astral-sh/python-build-standalone/releases/download`。
其他用户配置原样保留,不依赖 `.bak` 恢复旧 URL。

指定镜像代码时,若该代码同时提供 PyPI 与 Python 下载镜像(例如 `nju`),两部分使用同一镜像代码;仅提供其中一类时,另一类自动测速。用户自定义 URL 只解释为 PyPI index URL,因为 Python 下载镜像要求完全不同的 releases 目录布局。

`default = true` 的 index(不存在时取第一个)被视为 PyPI 替代源,reset 只修改这一处;私有 index 不受影响。

<br>

## 实现边界

配置改写器只解析 chsrc 使用的 TOML 子集,但支持常见的行首缩进、CRLF、行尾注释、多个 index,以及位于 `[tool.uv.sources]` 等子表之后的 `[[tool.uv.index]]`。读取时换行统一为 LF 处理,写入时按系统平台输出行尾(Windows 为 CRLF,其余为 LF)。多行字符串和完整 TOML 转义语义不属于该轻量改写器的支持范围。

参考:

- [uv index 设置](https://docs.astral.sh/uv/reference/settings/#index)
- [uv python-install-mirror 设置](https://docs.astral.sh/uv/reference/settings/#python-install-mirror)
- [uv 配置文件](https://docs.astral.sh/uv/concepts/configuration-files/)
- [uv package indexes](https://docs.astral.sh/uv/concepts/indexes/)

<br>
Loading